/* =====================================================
   Tailwind Color Finder — style.css
   Purple dark/light theme
   ===================================================== */

:root {
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --bg: #0f172a;
    --surface: #1e293b;
    --surface2: #293548;
    --border: rgba(139, 92, 246, 0.2);
    --text: #f1f5f9;
    --text-muted: #64748b;
    --radius: 14px;
    --transition: 0.2s ease;
}

[data-theme="light"] {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface2: #f1f5f9;
    --border: rgba(139, 92, 246, 0.2);
    --text: #0f172a;
    --text-muted: #64748b;
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background var(--transition);
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 20% -10%, rgba(139, 92, 246, 0.12) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

::-webkit-scrollbar {
    width: 5px;
}

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

.hidden {
    display: none !important;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.9);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px);
}

[data-theme="light"] .header {
    background: rgba(248, 250, 252, 0.9);
}

.header-inner {
    max-width: 860px;
    margin: 0 auto;
    padding: 13px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-swatch {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid rgba(139, 92, 246, 0.3);
    transition: background 0.3s ease;
}

.logo-title {
    font-size: 1rem;
    font-weight: 700;
}

.logo-sub {
    font-size: 0.63rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.theme-toggle {
    width: 36px;
    height: 36px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text);
    font-size: 1rem;
    transition: all var(--transition);
}

.theme-toggle:hover {
    border-color: var(--primary);
    transform: rotate(20deg);
}

/* Main container */
.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    z-index: 1;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* Input card */
.input-card {
    padding: 20px;
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
}

.color-preview-wrap {
    position: relative;
    flex-shrink: 0;
}

.color-picker {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.color-preview {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: transform var(--transition);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.color-preview:hover {
    transform: scale(1.08);
}

.hex-input-group {
    flex: 1;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.input-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.hex-input {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    padding: 12px 14px;
    outline: none;
    transition: border-color var(--transition);
    width: 100%;
}

.hex-input:focus {
    border-color: var(--primary);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 12px 24px;
    cursor: pointer;
    white-space: nowrap;
    transition: box-shadow var(--transition), transform var(--transition);
}

.btn-primary:hover {
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
    transform: translateY(-1px);
}

.recent-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.recent-row::before {
    content: 'Recent:';
    font-size: 0.7rem;
    color: var(--text-muted);
}

.recent-chip {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    transition: transform var(--transition);
}

.recent-chip:hover {
    transform: scale(1.2);
}

/* Results */
.results-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-header {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.result-inner {
    display: flex;
    align-items: stretch;
}

.result-swatch {
    width: 100px;
    flex-shrink: 0;
}

.result-info {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.result-rank {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.result-class {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--primary);
}

.result-hex {
    font-size: 0.85rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-muted);
}

.result-delta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.result-delta-val {
    color: var(--text);
    font-weight: 600;
}

.result-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.btn-copy {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 4px 10px;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-copy:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.delta-bar-wrap {
    padding: 16px 16px 16px 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    min-width: 140px;
}

.delta-bar-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.delta-label {
    font-size: 0.6rem;
    font-family: 'JetBrains Mono';
    color: var(--text-muted);
    width: 10px;
}

.delta-bar-bg {
    flex: 1;
    height: 6px;
    background: var(--surface2);
    border-radius: 3px;
    overflow: hidden;
}

.delta-bar {
    height: 100%;
    border-radius: 3px;
}

.badge-exact {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 700;
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

/* Palette browser */
.palette-card {
    overflow: hidden;
}

.palette-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.palette-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.palette-search {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.8rem;
    padding: 6px 10px;
    outline: none;
    transition: border-color var(--transition);
    width: 200px;
}

.palette-search:focus {
    border-color: var(--primary);
}

.palette-grid {
    padding: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 420px;
    overflow-y: auto;
}

.palette-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: transform var(--transition);
    role: listitem;
}

.palette-item:hover {
    transform: scale(1.1);
}

.palette-swatch {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: 1.5px solid rgba(255, 255, 255, 0.08);
}

.palette-name {
    font-size: 0.55rem;
    font-family: 'JetBrains Mono';
    color: var(--text-muted);
    text-align: center;
    max-width: 46px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .container {
        padding: 14px;
    }

    .result-swatch {
        width: 64px;
    }

    .delta-bar-wrap {
        display: none;
    }
}