/* ============================================================
   Color Palette Generator — Styles
   Pixel-close clone of reference design system generator
   ============================================================ */

/* --- CSS Custom Properties (Dark Theme) --- */
:root {
    /* Backgrounds */
    --bg-root: #08080f;
    --bg-surface: #0c0c17;
    --bg-elevated: #11111d;
    --bg-hover: #181827;
    --bg-active: #1f1f32;
    --bg-input: #0a0a15;

    /* Borders */
    --border-default: rgba(255, 255, 255, 0.06);
    --border-strong: rgba(255, 255, 255, 0.10);
    --border-accent: rgba(99, 102, 241, 0.30);

    /* Text */
    --text-primary: #f1f1f5;
    --text-secondary: #a0a0b0;
    --text-muted: #6b6b80;
    --text-inverse: #0a0a13;

    /* Brand / Accent */
    --accent-primary: #6366f1;
    --accent-primary-hover: #5558e6;
    --accent-primary-soft: rgba(99, 102, 241, 0.12);
    --accent-primary-glow: rgba(99, 102, 241, 0.25);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 10px;
    --space-lg: 12px;
    --space-xl: 20px;
    --space-2xl: 24px;
    --space-3xl: 32px;

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 12px;
    --radius-full: 9999px;

    /* Typography */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.8125rem;
    --font-size-base: 0.875rem;
    --font-size-md: 0.9375rem;
    --font-size-lg: 1rem;
    --font-size-xl: 1.125rem;
    --font-size-2xl: 1.25rem;
    --font-size-3xl: 1.5rem;

    /* Element-specific font sizes */
    --font-size-section-title: 2rem;
    --font-size-color-field-label: 0.8125rem;
    --font-size-results-title: 1.75rem;
    --font-size-color-group-title: 2rem;
    --font-size-color-scale-name: 1rem;
    --font-size-switch-label: 0.8125rem;
    --font-size-colors-label: 0.8125rem;

    /* Element-specific gaps / spacings */
    --gap-panel-section: 10px;
    --gap-section-header: 2px;
    --gap-color-inputs: 8px;
    --gap-color-field: 2px;
    --gap-color-group: 25px;
    --gap-group-header: 2px;
    --gap-group-content: 50px;
    --gap-color-scale: 12px;
    --gap-results-section: 20px;
    --gap-results-header: 2px;
    --gap-swatch-grid: 10px;
    --gap-swatch-square: 4px;
    --gap-color-groups: 24px;
    --gap-controls-panel: 12px;
    --gap-results-panel-padding: 24px;
    --gap-controls-panel-padding: 24px;

    /* Button padding */
    --btn-padding-y: 10px;
    --btn-padding-x: 12px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
    --transition-slow: 300ms ease;
}

/* --- Light Theme Overrides --- */
[data-theme="light"] {
    --bg-root: #f8f8fc;
    --bg-surface: #ffffff;
    --bg-elevated: #f0f0f5;
    --bg-hover: #e8e8f0;
    --bg-active: #dddde8;
    --bg-input: #f4f4f8;

    --border-default: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.12);

    --text-primary: #1a1a2e;
    --text-secondary: #5a5a70;
    --text-muted: #9090a0;
    --text-inverse: #ffffff;

    --accent-primary-soft: rgba(99, 102, 241, 0.08);
    --accent-primary-glow: rgba(99, 102, 241, 0.15);
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-root);
}

img, svg {
    display: block;
    max-width: 100%;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-size: inherit;
}

input {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    border: none;
    outline: none;
    background: none;
}

a {
    color: inherit;
    text-decoration: none;
}

/* --- Wrapper --- */
.wrapper {
    display: flex;
    height: 100vh;
}

/* ============================================================
   THEME TOGGLE SWITCH
   ============================================================ */
.theme-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.theme-toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-toggle-slider {
    display: block;
    width: 32px;
    height: 18px;
    background: var(--text-muted);
    border-radius: var(--radius-full);
    position: relative;
    transition: background var(--transition-normal);
}

.theme-toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition-normal);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.theme-toggle-input:checked + .theme-toggle-slider {
    background: var(--accent-primary);
}

.theme-toggle-input:checked + .theme-toggle-slider::after {
    transform: translateX(14px);
}

.theme-toggle-input:not(:checked) + .theme-toggle-slider {
    background: var(--text-muted);
}

/* Settings section */
.settings-section {
    display: flex;
    flex-direction: column;
    gap: var(--gap-panel-section);
}

.settings-section .label-with-icon {
    gap: var(--space-sm);
    font-size: var(--font-size-switch-label);
    font-weight: 500;
    color: var(--text-secondary);
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    position: relative;
}

.settings-label {
    font-size: var(--font-size-xs);
    font-weight: 400;
    color: var(--text-muted);
    flex: 1;
}

/* Mode selector — styled like export button */
.mode-selector {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 3px var(--space-sm);
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
    cursor: pointer;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
    transition: all var(--transition-fast);
    user-select: none;
    outline: none;
    min-width: 120px;
    z-index: 2;
}

.mode-selector:hover {
    background: var(--bg-active);
    border-color: var(--border-strong);
}

.mode-selector:focus-visible {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary-soft);
}

.mode-label {
    font-weight: 600;
    font-size: var(--font-size-sm);
    min-width: 80px;
    text-align: left;
}

.mode-selector svg {
    flex-shrink: 0;
    color: var(--text-muted);
    margin-left: auto;
}

.mode-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 140px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    z-index: 100;
    display: none;
    animation: dropdownIn var(--transition-fast) ease-out;
}

.mode-dropdown.visible {
    display: block;
}

.mode-option {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    cursor: pointer;
    text-align: left;
}

.mode-option:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.mode-option svg {
    opacity: 0;
    transition: opacity var(--transition-fast);
    flex-shrink: 0;
}

.mode-option.active svg {
    opacity: 1;
    color: var(--accent-primary);
}

.mode-option + .mode-option {
    border-top: 1px solid var(--border-default);
}

/* Theme switch row in left panel */
.theme-switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    margin-top: var(--space-xs);
}

.theme-switch-row .label-with-icon {
    gap: var(--space-sm);
    font-size: var(--font-size-switch-label);
    font-weight: 500;
    color: var(--text-secondary);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
    flex: 1;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

.content-grid {
    display: flex;
    width: 100%;
    max-width: 1600px;
    gap: 0;
}

/* ============================================================
   LEFT PANEL — CONTROLS
   ============================================================ */
.controls-panel {
    width: 340px;
    min-width: 340px;
    display: flex;
    flex-direction: column;
    padding: var(--gap-controls-panel-padding);
    gap: var(--gap-controls-panel);
    border-right: 1px solid var(--border-default);
    background: var(--bg-root);
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
}

.panel-section {
    display: flex;
    flex-direction: column;
    gap: var(--gap-panel-section);
}

.section-header {
    display: flex;
    flex-direction: column;
    gap: var(--gap-section-header);
}

.section-title {
    font-size: var(--font-size-section-title);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.section-desc {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    line-height: 1.4;
}

/* Color Inputs */
.color-inputs {
    display: flex;
    flex-direction: column;
    gap: var(--gap-color-inputs);
}

.label-with-icon {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-secondary);
    font-size: var(--font-size-colors-label);
    font-weight: 500;
}

.label-with-icon svg {
    color: var(--icon-color, var(--text-muted));
    flex-shrink: 0;
}

/* Color Inputs Label (no format selector) */
.color-inputs-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.color-field {
    display: flex;
    flex-direction: column;
    gap: var(--gap-color-field);
}

.color-field-label {
    font-size: var(--font-size-color-field-label);
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.color-field-input-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-xs);
    transition: border-color var(--transition-fast);
}

.color-field-input-group:focus-within {
    border-color: var(--border-accent);
}

.color-swatch-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-strong);
    cursor: pointer;
    flex-shrink: 0;
    transition: transform var(--transition-fast), border-color var(--transition-fast);
    position: relative;
}

.color-swatch-btn:hover {
    transform: scale(1.05);
    border-color: var(--accent-primary);
}

.color-hex-input {
    flex: 1;
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-sm);
    font-weight: 500;
    font-family: 'SF Mono', 'Consolas', 'Courier New', monospace;
    color: var(--text-primary);
    background: transparent;
    min-width: 0;
    letter-spacing: 0.5px;
}

.color-hex-input::placeholder {
    color: var(--text-muted);
}

.color-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.color-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.color-action-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.color-action-btn.locked {
    color: var(--accent-primary);
}

.native-color-picker {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* Random Button */
.random-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--btn-padding-y) var(--btn-padding-x);
    border-radius: var(--radius-md);
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    border: 1px solid var(--border-default);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.random-btn:hover {
    background: var(--bg-active);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.random-btn svg,
.export-btn svg {
    color: var(--icon-color, var(--text-muted));
    flex-shrink: 0;
}

/* Divider */
.panel-divider {
    height: 1px;
    background: var(--border-default);
    margin: var(--space-xs) 0;
}

/* Export */
.panel-export {
    position: relative;
}

.export-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--btn-padding-y) var(--btn-padding-x);
    border-radius: var(--radius-md);
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    border: 1px solid var(--border-default);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.export-btn:hover {
    background: var(--bg-active);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.export-btn .chevron-down {
    margin-left: auto;
    transition: transform var(--transition-fast);
}

.export-btn.open .chevron-down {
    transform: rotate(180deg);
}

.export-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    z-index: 50;
    display: none;
    animation: dropdownIn var(--transition-fast) ease-out;
}

.export-dropdown.visible {
    display: block;
}

@keyframes dropdownIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.export-option {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    cursor: pointer;
    text-align: left;
}

.export-option:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.export-option + .export-option {
    border-top: 1px solid var(--border-default);
}

/* ============================================================
   RIGHT PANEL — RESULTS
   ============================================================ */
.results-panel {
    flex: 1;
    padding: var(--gap-results-panel-padding);
    min-width: 0;
    overflow-y: auto;
    height: 100vh;
}

.results-section {
    display: flex;
    flex-direction: column;
    gap: var(--gap-results-section);
    width: 100%;
}

.results-section-header {
    display: flex;
    flex-direction: column;
    gap: var(--gap-results-header);
}

.results-section-title {
    font-size: var(--font-size-results-title);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.results-section-desc {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    line-height: 1.5;
}

/* Color Groups */
.color-groups {
    display: flex;
    flex-direction: column;
    gap: var(--gap-color-groups);
}

.color-group {
    display: flex;
    flex-direction: column;
    gap: var(--gap-color-group);
}

.color-group-header {
    display: flex;
    flex-direction: column;
    gap: var(--gap-group-header);
}

.color-group-title {
    font-size: var(--font-size-color-group-title);
    font-weight: 600;
    color: var(--text-primary);
}

.color-group-desc {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.color-group-content {
    display: flex;
    flex-direction: column;
    gap: var(--gap-group-content);
}

.color-scale {
    display: flex;
    flex-direction: column;
    gap: var(--gap-color-scale);
}

.color-scale-name {
    font-size: var(--font-size-color-scale-name);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.color-scale-swatches {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: var(--gap-swatch-grid);
}

/* Container that holds swatches grid + table vertically */
.color-scale-content {
    display: flex;
    flex-direction: column;
    gap: var(--gap-color-scale);
}

/* Individual Swatch Square — evenly divides row */
.swatch-square {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--gap-swatch-square);
    cursor: pointer;
    transition: transform var(--transition-fast);
    position: relative;
}

.swatch-square:hover {
    transform: translateY(-2px);
}

.swatch-square:active {
    transform: translateY(0);
}

.swatch-square-color {
    width: 100%;
    aspect-ratio: 1.4 / 1;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.10);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.swatch-square:hover .swatch-square-color {
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.swatch-square-label {
    font-size: clamp(8px, 1vw, 11px);
    font-weight: 500;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Consolas', 'Courier New', monospace;
    letter-spacing: 0.1px;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

/* Swatch Table (below the squares) — scales with viewport */
.swatch-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--space-md);
}

.swatch-table thead th {
    text-align: left;
    padding: clamp(4px, 0.6vw, 12px) clamp(8px, 1vw, 20px);
    font-size: clamp(9px, 0.7vw, 12px);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}

.swatch-table thead th:last-child {
    width: auto;
}

.swatch-table-row {
    cursor: pointer;
    transition: background var(--transition-fast);
}

.swatch-table-row:hover {
    background: var(--bg-hover);
}

.swatch-table-row td {
    padding: clamp(4px, 0.6vw, 12px) clamp(8px, 1vw, 20px);
    font-size: clamp(11px, 0.8vw, 14px);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-default);
    vertical-align: middle;
    white-space: nowrap;
}

.swatch-table-row td:last-child {
    width: auto;
}

.swatch-table-preview {
    display: inline-block;
    width: clamp(22px, 2vw, 36px);
    height: clamp(16px, 1.4vw, 26px);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.10);
    flex-shrink: 0;
    vertical-align: middle;
}

.swatch-table-label {
    font-weight: 600;
    font-family: 'SF Mono', 'Consolas', 'Courier New', monospace;
    font-size: clamp(10px, 0.7vw, 13px);
    color: var(--text-secondary);
}

.swatch-table-hex {
    font-family: 'SF Mono', 'Consolas', 'Courier New', monospace;
    font-size: clamp(10px, 0.7vw, 13px);
    color: var(--text-primary);
    letter-spacing: 0.3px;
}

.swatch-table-rgb {
    font-family: 'SF Mono', 'Consolas', 'Courier New', monospace;
    font-size: clamp(10px, 0.7vw, 13px);
    color: var(--text-muted);
}

.swatch-copy-hint {
    font-size: clamp(8px, 0.6vw, 11px);
    color: var(--text-muted);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.swatch-table-row:hover .swatch-copy-hint {
    opacity: 1;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-3xl) var(--space-xl);
    gap: var(--space-lg);
    margin-top: var(--space-3xl);
}

.empty-state-icon {
    color: var(--text-muted);
    opacity: 0.4;
    margin-bottom: var(--space-sm);
}

.empty-state-icon svg {
    width: 64px;
    height: 64px;
}

.empty-state-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text-secondary);
}

.empty-state-desc {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    max-width: 320px;
    line-height: 1.5;
}

.empty-state.hidden {
    display: none;
}

.results-section.hidden {
    display: none;
}

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-full);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-slow) cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast svg {
    color: #22c55e;
    flex-shrink: 0;
}

.toast-message {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
}

/* ============================================================
   FOOTER


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

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

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .content-grid {
        flex-direction: column;
    }

.controls-panel {
        width: 100%;
        min-width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border-default);
    }

    .results-panel {
        height: auto;
        padding: var(--space-xl);
    }
}

@media (max-width: 500px) {
    .controls-panel {
        padding: var(--space-lg);
    }

    .results-panel {
        padding: var(--space-lg);
    }


}
