/* ===== CSS Variables & Theming ===== */
:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-glass: rgba(26, 26, 46, 0.7);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b8;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.3);
    --border-color: rgba(255, 255, 255, 0.1);
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 20px;
    --border-radius-xl: 28px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.8);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: rgba(0, 0, 0, 0.1);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.app-container {
    position: relative;
    min-height: 100vh;
    padding: var(--space-lg);
}

.bg-orbs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 600px;
    height: 600px;
    background: var(--accent-primary);
    top: -200px;
    right: -200px;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: var(--accent-secondary);
    bottom: -100px;
    left: -100px;
    animation-delay: -7s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: #a855f7;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(-20px, 20px) scale(0.95);
    }
}

.glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 1;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
    padding: var(--space-md) 0;
    position: relative;
    z-index: 10;
    flex-wrap: wrap;
    gap: var(--space-md);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo-icon {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    padding: 6px;
    background: var(--bg-glass);
    border-radius: var(--border-radius-sm);
}

.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    animation: dotPulse 2s ease-in-out infinite;
}

.dot-1 {
    background: #6366f1;
}

.dot-2 {
    background: #8b5cf6;
    animation-delay: 0.2s;
}

.dot-3 {
    background: #a855f7;
    animation-delay: 0.4s;
}

.dot-4 {
    background: #22c55e;
    animation-delay: 0.6s;
}

@keyframes dotPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.85);
    }
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo h1 span {
    font-weight: 400;
    opacity: 0.8;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border: none;
    border-radius: var(--border-radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--accent-primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px dashed var(--border-color);
}

.btn-ghost:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.icon-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--bg-glass);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-normal);
    border: 1px solid var(--border-color);
}

.icon-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: rotate(15deg);
}

.icon-btn svg {
    width: 22px;
    height: 22px;
}

[data-theme="light"] .sun-icon {
    display: none;
}

[data-theme="light"] .moon-icon {
    display: block;
}

.moon-icon {
    display: none;
}

.sun-icon {
    display: block;
}

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
    position: relative;
    z-index: 1;
}

.controls-section {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-lg);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.control-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.color-input-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--bg-secondary);
    padding: var(--space-sm);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
}

input[type="color"] {
    -webkit-appearance: none;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: var(--border-radius-sm);
}

#hex-input {
    width: 100px;
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: monospace;
    font-size: 0.95rem;
    text-transform: uppercase;
}

#hex-input:focus {
    outline: none;
}

select {
    padding: var(--space-sm) var(--space-lg);
    padding-right: var(--space-2xl);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
    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='%23a0a0b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

select:hover,
select:focus {
    border-color: var(--accent-primary);
    outline: none;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 120px;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-gradient);
    border-radius: 50%;
    cursor: pointer;
}

.palette-container {
    display: flex;
    min-height: 280px;
    border-radius: var(--border-radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.palette-color {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: var(--space-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    min-width: 80px;
    animation: fadeIn 0.5s ease-out both;
}

.palette-color:hover {
    flex: 1.5;
}

.palette-color::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.5), transparent);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.palette-color:hover::before {
    opacity: 1;
}

.color-info {
    position: relative;
    z-index: 1;
    opacity: 0;
    transform: translateY(10px);
    transition: all var(--transition-normal);
}

.palette-color:hover .color-info {
    opacity: 1;
    transform: translateY(0);
}

.color-hex {
    font-family: monospace;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: var(--space-xs);
}

.color-rgb {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
}

.color-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.color-action-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: var(--border-radius-sm);
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.color-action-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.color-action-btn svg {
    width: 16px;
    height: 16px;
}

.accessibility-section h2,
.export-section h2,
.saved-section h2 {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: var(--space-lg);
}

.accessibility-section h2 svg,
.export-section h2 svg,
.saved-section h2 svg {
    width: 24px;
    height: 24px;
    color: var(--accent-primary);
}

.accessibility-controls {
    display: flex;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.color-select {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.color-select label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.color-select select {
    min-width: 150px;
}

.contrast-result {
    display: flex;
    gap: var(--space-xl);
    align-items: center;
    flex-wrap: wrap;
}

.contrast-preview {
    flex: 1;
    min-width: 200px;
}

.preview-box {
    padding: var(--space-xl);
    border-radius: var(--border-radius-md);
    text-align: center;
    font-size: 1.2rem;
    font-weight: 500;
}

.contrast-scores {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.score-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.score-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.score-value {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: monospace;
}

.score-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
}

.score-badge.pass {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.score-badge.fail {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.export-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.btn-export {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: var(--space-md) var(--space-lg);
}

.btn-export:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
}

.btn-export.active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
}

.format-icon {
    font-size: 0.75rem;
    font-weight: 700;
    padding: var(--space-xs) var(--space-sm);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.export-preview {
    display: none;
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-md);
    overflow: hidden;
}

.export-preview.visible {
    display: block;
}

.export-preview pre {
    padding: var(--space-lg);
    overflow-x: auto;
    max-height: 200px;
}

.export-preview code {
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.btn-copy {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    padding: var(--space-xs) var(--space-md);
    font-size: 0.8rem;
    background: var(--accent-primary);
    color: white;
    border-radius: var(--border-radius-sm);
}

.btn-save {
    margin-bottom: var(--space-lg);
}

.saved-palettes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--space-md);
}

.saved-palette-item {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition-normal);
    border: 1px solid var(--border-color);
}

.saved-palette-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-primary);
}

.saved-palette-colors {
    display: flex;
    height: 60px;
}

.saved-palette-colors span {
    flex: 1;
}

.saved-palette-info {
    padding: var(--space-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.saved-palette-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.delete-palette-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--border-radius-sm);
}

.delete-palette-btn:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.no-saved-palettes {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-secondary);
}

.toast {
    position: fixed;
    bottom: var(--space-xl);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transition: all var(--transition-normal);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    border-color: var(--success);
}

@media (max-width: 768px) {
    .app-container {
        padding: var(--space-md);
    }

    .header {
        flex-direction: column;
        text-align: center;
    }

    .controls-section {
        flex-direction: column;
        align-items: stretch;
    }

    .palette-container {
        flex-direction: column;
        min-height: auto;
    }

    .palette-color {
        min-height: 80px;
    }

    .palette-color:hover {
        flex: 1;
    }

    .color-info {
        opacity: 1;
        transform: translateY(0);
    }

    .export-buttons {
        flex-direction: column;
    }

    .btn-export {
        width: 100%;
        justify-content: center;
    }
}