:root {
    /* Dark Theme */
    --bg-main: #0F1219;
    --bg-panel: rgba(22, 26, 36, 0.7);
    --bg-card: rgba(30, 35, 48, 0.8);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(99, 102, 241, 0.4);
    --text-main: #F3F4F6;
    --text-muted: #9CA3AF;
    --primary: #6366F1;
    --primary-hover: #4F46E5;
    
    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

body.light-theme {
    --bg-main: #F9FAFB;
    --bg-panel: rgba(255, 255, 255, 0.9);
    --bg-card: rgba(243, 244, 246, 0.9);
    --border-color: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(99, 102, 241, 0.4);
    --text-main: #111827;
    --text-muted: #6B7280;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

.hidden { display: none !important; }
.mt-4 { margin-top: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-auto { margin-top: auto; }
.h-full { height: 100%; }
.w-full { width: 100%; }
.flex-col { display: flex; flex-direction: column; }
.flex-1 { flex: 1; min-height: 0; }

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.btn-icon:hover {
    color: var(--text-main);
    background: var(--border-color);
}

/* Main Layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 450px;
    gap: 24px;
    flex: 1;
    min-height: 0;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        height: auto;
    }
    .app-container { height: auto; }
}

/* Glass Panels */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.2);
}

body.light-theme .glass-panel {
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.05);
}

/* Left Panel: Dropzone & Preview */
.drop-zone {
    flex: 1;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    cursor: pointer;
    background: rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

body.light-theme .drop-zone { background: rgba(255,255,255,0.4); }

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.drop-content {
    text-align: center;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.drop-content svg { color: var(--primary); margin-bottom: 8px; }
.drop-content h3 { font-size: 1.25rem; font-weight: 600; color: var(--text-main); margin-bottom: 4px; }
.badge { background: var(--bg-card); padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; text-transform: uppercase; font-weight: 600; }

.preview-container {
    flex: 1;
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

#image-preview {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.btn-clear {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
    z-index: 10;
}
.btn-clear:hover { background: rgba(220, 38, 38, 0.8); transform: scale(1.05); }

/* Right Panel: Results */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.results-header h2 { font-size: 1.25rem; font-weight: 600; }

.format-toggle {
    display: flex;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 4px;
    border: 1px solid var(--border-color);
}
.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.toggle-btn.active {
    background: var(--primary);
    color: white;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
}

.section-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Dominant Card */
.dominant-color-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
}

.color-preview {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-sm);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}

.color-details {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.code {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 1px;
}

/* Buttons */
.btn-copy {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-copy:hover {
    border-color: var(--border-hover);
    color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: inherit;
}
.btn-secondary {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.05);
    border-color: var(--border-hover);
}
body.light-theme .btn-secondary:hover { background: rgba(0,0,0,0.05); }

/* Palette Grid */
.palette-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.swatch-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
    transition: transform 0.2s;
    position: relative;
}

.swatch:hover {
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3), inset 0 0 0 1px rgba(0,0,0,0.1);
}

.swatch-label {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Harmonies */
.harmonies-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.harmony-block {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
}
.harmony-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.harmony-colors {
    display: flex;
    gap: 8px;
}

.export-section {
    padding-top: 24px;
    border-top-color: var(--border-color);
}
.export-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: var(--bg-main);
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 1000;
    transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 20px);
}
