/* =========================================================
   Sprite Forge - Design System
   Deeplek.com Theme (Light, Clean, Vibrant Pink)
   ========================================================= */

/* --- IMPORTS --- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&family=Roboto:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* --- CUSTOM PROPERTIES --- */
:root {
    /* Colors - Light Theme based on deeplek.com */
    --bg-primary: #f8f9fa; /* Fundo principal claro */
    --bg-secondary: #ffffff;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f1f3f5;
    --bg-glass: rgba(255, 255, 255, 0.95);
    
    --border-subtle: rgba(0, 0, 0, 0.05);
    --border-medium: rgba(0, 0, 0, 0.1);
    --border-bright: rgba(0, 0, 0, 0.15);
    
    --text-primary: #333333; /* Cor do texto escuro do wp */
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --text-accent: #3BB4B4; /* Cor primária do deeplek */
    
    --accent-primary: #3BB4B4;
    --accent-secondary: #E47911; /* Laranja Elementor */
    --accent-gradient: linear-gradient(135deg, #E47911, #D2680D);
    --accent-gradient-hover: linear-gradient(135deg, #D2680D, #B8590A);
    --accent-glow: rgba(228, 121, 17, 0.3);
    --accent-glow-cyan: rgba(59, 180, 180, 0.2);
    
    --success: #34d399;
    --success-bg: rgba(52, 211, 153, 0.1);
    --error: #f87171;
    --error-bg: rgba(248, 113, 113, 0.1);
    --info: #60a5fa;
    --info-bg: rgba(96, 165, 250, 0.1);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.1);
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    
    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    
    /* Shadows - Ajustadas para tema claro */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.12);
    
    /* Typography */
    --font-sans: 'Poppins', sans-serif;
    --font-heading: 'Roboto', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* --- RESET --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    opacity: 0;
    transition: opacity 0.5s ease;
}

body.loaded {
    opacity: 1;
}

/* Removido o background de drift escuro para manter o visual limpo do deeplek */

@keyframes ambientDrift {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-3%, -2%) rotate(2deg); }
}

/* --- LAYOUT --- */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1280px;
    margin: 0 auto;
    padding: var(--space-lg);
    min-height: 100vh;
}

/* --- HEADER --- */
.app-header {
    text-align: center;
    padding: var(--space-xl) var(--space-lg);
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-subtle);
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: var(--shadow-glow);
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { box-shadow: 0 0 20px var(--accent-glow); }
    50% { box-shadow: 0 0 40px var(--accent-glow), 0 0 60px var(--accent-glow-cyan); }
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 42px;
    font-weight: 700;
    color: var(--accent-primary);
}

.app-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 0.02em;
}

.app-subtitle span {
    color: var(--text-primary);
    font-weight: 500;
}

/* --- GLASS PANELS --- */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-lg);
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.glass-panel:hover {
    border-color: var(--border-medium);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.panel-icon {
    font-size: 18px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(72, 193, 185, 0.1);
    border-radius: var(--radius-sm);
}

.panel-title {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

/* --- MAIN GRID --- */
.main-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: var(--space-lg);
    align-items: start;
}

@media (max-width: 900px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

/* --- LEFT SIDEBAR --- */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.btn-remove-image {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #ff4757;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    line-height: 1;
}

.btn-remove-image:hover {
    transform: scale(1.1);
    background: #ff6b81;
}

/* --- DROP ZONE --- */
.drop-zone {
    border: 2px dashed var(--border-medium);
    border-radius: var(--radius-lg);
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    animation: dropZonePulse 2.5s infinite ease-in-out;
}

@keyframes dropZonePulse {
    0%, 100% { border-color: var(--border-medium); box-shadow: none; }
    50% { border-color: var(--accent-primary); box-shadow: 0 0 15px rgba(59, 180, 180, 0.2); }
}

.drop-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition-normal);
    border-radius: inherit;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
    animation: none;
}

.drop-zone:hover::before,
.drop-zone.drag-over::before {
    opacity: 0.05;
}

.drop-zone-content {
    position: relative;
    z-index: 1;
}

.drop-icon {
    font-size: 40px;
    margin-bottom: var(--space-md);
    opacity: 0.6;
}

.drop-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.drop-subtitle {
    font-size: 12px;
    color: var(--text-tertiary);
}

.drop-formats {
    display: inline-flex;
    gap: var(--space-xs);
    margin-top: var(--space-md);
}

.format-tag {
    font-size: 10px;
    font-family: var(--font-mono);
    font-weight: 500;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: rgba(72, 193, 185, 0.1);
    color: var(--text-accent);
    border: 1px solid rgba(72, 193, 185, 0.15);
}

/* --- FILE INFO BAR --- */
.file-info {
    display: none;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    font-size: 12px;
    border: 1px solid var(--border-subtle);
}

.file-info.active {
    display: flex;
}

.file-info-name {
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.file-info-dim {
    font-family: var(--font-mono);
    color: var(--text-accent);
    font-size: 11px;
}

/* --- SETTINGS --- */
.settings-group {
    margin-bottom: var(--space-lg);
}

.settings-group:last-child {
    margin-bottom: 0;
}

.setting-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.setting-value {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-accent);
    background: rgba(72, 193, 185, 0.1);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

/* Size buttons */
.size-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
}

.size-btn {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.size-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.size-btn.active {
    border-color: var(--accent-primary);
    background: rgba(72, 193, 185, 0.15);
    color: var(--text-primary);
    box-shadow: 0 0 12px var(--accent-glow);
}

/* Custom size inputs */
.custom-size-inputs {
    display: none;
    grid-template-columns: 1fr auto 1fr;
    gap: var(--space-sm);
    align-items: center;
    margin-top: var(--space-sm);
}

.custom-size-inputs.active {
    display: grid;
}

.custom-size-input {
    padding: var(--space-sm);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    text-align: center;
    width: 100%;
    outline: none;
    transition: border-color var(--transition-fast);
}

.custom-size-input:focus {
    border-color: var(--accent-primary);
}

.custom-size-x {
    font-family: var(--font-mono);
    color: var(--text-tertiary);
    font-size: 12px;
    text-align: center;
}

/* Slider */
.slider-container {
    position: relative;
    height: 6px;
    background: var(--border-medium);
    border-radius: var(--radius-full);
    overflow: visible;
}

.slider-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    pointer-events: none;
    transition: width 50ms linear;
}

.slider-input {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    transform: translateY(-50%);
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: transparent;
    cursor: pointer;
    outline: none;
    margin: 0;
}

.slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--text-primary);
    border-radius: 50%;
    border: 3px solid var(--accent-primary);
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-glow);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.slider-input::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 16px var(--accent-glow);
}

.slider-input::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--text-primary);
    border-radius: 50%;
    border: 3px solid var(--accent-primary);
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Toggle */
.toggle-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
}

.toggle-btn:hover {
    border-color: var(--border-bright);
    color: var(--text-primary);
}

.toggle-btn.active {
    border-color: var(--accent-primary);
    background: rgba(72, 193, 185, 0.05);
    color: var(--accent-secondary);
}

.toggle-indicator {
    width: 36px;
    height: 20px;
    border-radius: var(--radius-full);
    background: var(--border-medium);
    position: relative;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

.toggle-indicator::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-tertiary);
    transition: all var(--transition-fast);
}

.toggle-btn.active .toggle-indicator {
    background: rgba(72, 193, 185, 0.3);
}

.toggle-btn.active .toggle-indicator::after {
    left: 18px;
    background: var(--accent-secondary);
}

/* --- PROCESS BUTTON --- */
.btn-process {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    border: none;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    color: white;
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.btn-process::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-gradient-hover);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn-process:hover:not(:disabled)::before {
    opacity: 1;
}

.btn-process:hover:not(:disabled) {
    box-shadow: var(--shadow-glow), 0 4px 20px rgba(72, 193, 185, 0.2);
    transform: translateY(-1px);
}

.btn-process:active:not(:disabled) {
    transform: translateY(0);
}

.btn-process:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-process .btn-text,
.btn-process .btn-icon {
    position: relative;
    z-index: 1;
}

.btn-process.processing {
    pointer-events: none;
}

.btn-process.processing .btn-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- PROGRESS BAR --- */
.progress-container {
    display: none;
    margin-top: var(--space-md);
}

.progress-container.active {
    display: block;
}

.progress-track {
    height: 4px;
    background: var(--border-medium);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: var(--space-xs);
}

.progress-bar {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    transition: width 200ms ease;
    width: 0%;
}

.progress-text {
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

/* --- RIGHT CONTENT AREA --- */
.content-area {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* --- EMPTY STATE --- */
#empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
}

.empty-state-content {
    max-width: 360px;
}

.empty-icon {
    font-size: 64px;
    opacity: 0.15;
    margin-bottom: var(--space-lg);
}

.empty-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.empty-text {
    font-size: 13px;
    color: var(--text-tertiary);
    line-height: 1.6;
}

/* --- WORKSPACE (shown after upload) --- */
#workspace {
    display: none;
}

#workspace.active {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    animation: fadeSlideUp 0.4s ease;
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- PREVIEW AREA --- */
.previews-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-lg);
    justify-content: center;
}

@media (max-width: 850px) {
    .previews-grid {
        flex-direction: column;
    }
    .preview-panel {
        min-width: 100%;
        max-width: 100% !important;
    }
}

.preview-panel {
    flex: 1 1 300px;
    min-height: 320px;
    display: flex;
    flex-direction: column;
}

/* Se tiver apenas 1 sprite gerado, ele ganha um limite máximo para não ficar deformado.
   Se tiver 2, 3 ou 4, eles esticam livremente para preencher as laterais! */
.preview-panel:only-child {
    max-width: 600px;
}

.preview-canvas-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    min-height: 250px;
    position: relative;
    border-radius: var(--radius-sm);
    
    /* Checkered transparency background for light theme */
    background-color: #ffffff;
    background-image:
        linear-gradient(45deg, rgba(0,0,0,0.05) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(0,0,0,0.05) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(0,0,0,0.05) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(0,0,0,0.05) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    border: 1px solid var(--border-subtle);
}

.preview-canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    display: block;
}

.zoom-badge {
    position: absolute;
    bottom: var(--space-sm);
    right: var(--space-sm);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.6);
    color: var(--text-secondary);
    backdrop-filter: blur(8px);
}

/* --- RESULT CONTAINER --- */
#result-container {
    display: none;
}

#result-container.active {
    display: block;
    animation: fadeSlideUp 0.4s ease;
}

/* --- GALLERY GRID --- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-md);
}

.gallery-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    padding: var(--space-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
}

.gallery-item-title {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    text-align: center;
}

.gallery-canvas-wrap {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background-color: #ffffff;
    background-image:
        linear-gradient(45deg, rgba(0,0,0,0.05) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(0,0,0,0.05) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(0,0,0,0.05) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(0,0,0,0.05) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    position: relative;
}

.gallery-canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.skeleton-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(72, 193, 185, 0.05);
    animation: pulse 1.5s ease-in-out infinite;
}

.loader-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-medium);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 2;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.btn-download-small {
    width: 100%;
    padding: var(--space-xs) var(--space-sm);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-sm);
    background: rgba(72, 193, 185, 0.08);
    color: var(--accent-primary);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.btn-download-small:hover {
    background: rgba(72, 193, 185, 0.15);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* --- RESULTS SECTION (stats + palette) --- */
#results-section {
    display: none;
}

#results-section.active {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    animation: fadeSlideUp 0.4s ease;
}

@media (max-width: 700px) {
    #results-section.active {
        grid-template-columns: 1fr;
    }
}

/* --- STATS --- */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.stat-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    font-weight: 500;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-value.highlight {
    color: var(--accent-secondary);
}

.stat-value.accent {
    color: var(--success);
}

/* --- PALETTE --- */
.palette-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.palette-count {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-accent);
}

.palette-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: var(--space-sm);
}

.palette-swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 2px solid transparent;
    position: relative;
}

.palette-swatch:hover {
    transform: scale(1.25);
    border-color: rgba(0, 0, 0, 0.3);
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

/* --- DOWNLOAD BUTTON --- */
.btn-download {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-md);
    background: rgba(72, 193, 185, 0.08);
    color: var(--accent-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.btn-download:hover:not(:disabled) {
    background: rgba(72, 193, 185, 0.15);
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-download:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* --- NOTIFICATIONS --- */
.notifications {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
}

.notification {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(16px);
    font-size: 13px;
    font-weight: 500;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    max-width: 400px;
    border: 1px solid;
}

.notification.show {
    transform: translateX(0);
    opacity: 1;
}

.notification-success {
    background: var(--success-bg);
    border-color: rgba(52, 211, 153, 0.2);
    color: var(--success);
}

.notification-error {
    background: var(--error-bg);
    border-color: rgba(248, 113, 113, 0.2);
    color: var(--error);
}

.notification-info {
    background: var(--info-bg);
    border-color: rgba(96, 165, 250, 0.2);
    color: var(--info);
}

.notification-warning {
    background: var(--warning-bg);
    border-color: rgba(251, 191, 36, 0.2);
    color: var(--warning);
}

.notification-icon {
    font-size: 16px;
    flex-shrink: 0;
}

/* --- FOOTER --- */
.app-footer {
    text-align: center;
    padding: var(--space-2xl) 0 var(--space-lg);
    font-size: 12px;
    color: var(--text-tertiary);
}

.app-footer a {
    color: var(--text-accent);
    text-decoration: none;
}

/* --- HIDDEN UTILITIES --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

input[type="file"] {
    display: none;
}

/* --- DITHER INFO TOOLTIP --- */
.info-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--border-medium);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
    cursor: help;
    position: relative;
    margin-left: var(--space-xs);
}

.info-tip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-sm) var(--space-md);
    background: #ffffff;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 400;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-fast);
    z-index: 100;
}

.info-tip:hover::after {
    opacity: 1;
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* --- ORIGINAL COLORS INDICATOR --- */
.original-info {
    display: none;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-md);
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

.original-info.active {
    display: flex;
}

.original-info .color-count {
    color: var(--error);
    font-weight: 600;
}

/* --- DARK THEME OVERRIDES --- */
body.dark-theme {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-surface: #242424;
    --bg-surface-hover: #2a2a2a;
    --bg-glass: rgba(30, 30, 30, 0.95);
    
    --border-subtle: rgba(255, 255, 255, 0.05);
    --border-medium: rgba(255, 255, 255, 0.1);
    --border-bright: rgba(255, 255, 255, 0.15);
    
    --text-primary: #f0f0f0;
    --text-secondary: #a0a0a0;
    --text-tertiary: #777777;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 5px 15px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(59, 180, 180, 0.15);
}

/* --- THEME TOGGLE BUTTON --- */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

.theme-toggle:hover {
    background: var(--bg-surface-hover);
    border-color: var(--accent-primary);
    transform: scale(1.1);
}

/* --- MOBILE RESPONSIVENESS FIXES --- */
@media (max-width: 600px) {
    .app-header {
        padding: var(--space-lg) var(--space-md);
    }
    .logo-text {
        font-size: 28px;
        white-space: nowrap;
    }
    .logo-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    .app-subtitle {
        font-size: 12px;
    }
    .theme-toggle {
        top: 15px;
        right: 15px;
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
}
