/* Global Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Default Light Theme */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-tertiary: #718096;
    --border-color: #e0e0e0;
    --border-hover: #4b5563;
    --button-bg: #4b5563;
    --button-hover: #374151;
    --button-disabled: #9ca3af;
    --header-bg: #ffffff;
    --header-border: #e0e0e0;
    --header-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    --upload-border: #d1d5db;
    --upload-hover: #f3f4f6;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #1e2a3a;
    --bg-secondary: #253545;
    --bg-tertiary: #2d3d4d;
    --text-primary: #e6e6e6;
    --text-secondary: #aab6c4;
    --text-tertiary: #9ca3af;
    --border-color: #3a4a5a;
    --border-hover: #4f46e5;
    --button-bg: #2a2475;
    --button-hover: #211b60;
    --button-disabled: #5549c5;
    --header-bg: #253545;
    --header-border: #3a4a5a;
    --header-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    --upload-border: #4a5a6a;
    --upload-hover: #334455;
}

/* Set dropdown arrow to white in dark mode */
[data-theme="dark"] .title-with-select .function-select {
    color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: all 0.3s ease;
}

/* Sticky Header */
.sticky-header {
    position: sticky;
    top: 0;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    box-shadow: var(--header-shadow);
    z-index: 1000;
    padding: 1rem 0;
    transition: all 0.3s ease;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.function-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.function-select:hover {
    border-color: var(--border-hover);
    background-color: var(--bg-secondary);
}

.status-indicator {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background-color: var(--bg-tertiary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    transition: all 0.3s ease;
    margin-left: 0.5rem;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--dot-color, #9ca3af); /* Default color */
    transition: all 0.3s ease;
}

.reset-btn {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.reset-btn:hover {
    background-color: var(--bg-secondary);
}

.theme-toggle-btn {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 36px;
    padding: 0;
}

.theme-toggle-btn:hover {
    background-color: var(--bg-secondary);
}

/* Main Content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Interfaces */
.interface {
    display: none;
}

.interface.active {
    display: block;
}

.title-with-select {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.title-with-select .function-select {
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 1.5rem;
    font-weight: 600;
    background-color: transparent;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 12px;
    padding-right: 2rem;
}

.title-with-select .function-select option {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
}

.supported-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Upload Section */
.upload-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.upload-section.single-column {
    grid-template-columns: 1fr;
}

.upload-column {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.upload-column:hover {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    background-color: var(--bg-tertiary);
}

.upload-column h3 {
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* File Upload */
.file-upload {
    width: 100%;
    padding: 1rem;
    border: 2px dashed var(--upload-border);
    border-radius: 0.375rem;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 1rem;
}

.file-upload:hover {
    border-color: var(--border-hover);
    background-color: var(--upload-hover);
}

.file-upload::-webkit-file-upload-button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--button-bg);
    border-radius: 0.375rem;
    background-color: var(--button-bg);
    color: white;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.file-upload::-webkit-file-upload-button:hover {
    background-color: var(--button-hover);
}

/* Ensure file upload button text is readable in dark mode */
[data-theme="dark"] .file-upload::-webkit-file-upload-button {
    color: white;
}

/* Image Preview */
.image-preview {
    width: 100%;
    height: 200px;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background-color: var(--bg-tertiary);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease;
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-preview p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Buttons */
.primary-btn {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 0.375rem;
    font-size: 1rem;
    font-weight: 500;
    background-color: var(--button-bg);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 2rem;
}

.primary-btn:hover {
    background-color: var(--button-hover);
}

.primary-btn:disabled {
    background-color: var(--button-disabled);
    cursor: not-allowed;
}

/* Results Section */
.results-section {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-top: 2rem;
    transition: all 0.3s ease;
}

.results-section h3 {
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.results-section img {
    max-width: 100%;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.results-section a {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 0.375rem;
    background-color: var(--button-bg);
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.results-section a:hover {
    background-color: var(--button-hover);
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    border-top: 1px solid var(--border-color);
    margin-top: 4rem;
    background-color: var(--bg-primary);
    transition: all 0.3s ease;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        padding: 0 1rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .upload-section {
        grid-template-columns: 1fr;
    }
    
    .control-group {
        width: 100%;
        justify-content: center;
    }
    
    .function-select {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .interface h2 {
        font-size: 1.5rem;
    }
    
    .header-left h1 {
        font-size: 1.25rem;
    }
}