/* =====================================================
   Font Pairing Suggestion Engine — style.css
   Typography Studio aesthetic
   ===================================================== */

/* ── Variables ─────────────────────────────────────── */
:root {
    --primary: #2C3E50;
    --accent: #E74C3C;
    --muted: #7F8C8D;
    --bg: #0F0F1A;
    --surface: #1A1A2E;
    --surface2: #16213E;
    --border: rgba(255, 255, 255, 0.09);
    --text: #ECF0F1;
    --text-muted: #95A5A6;
    --radius: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg: #F8F9FA;
    --surface: #FFFFFF;
    --surface2: #F0F2F5;
    --border: rgba(0, 0, 0, 0.08);
    --text: #2C3E50;
    --text-muted: #7F8C8D;
}

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

html {
    scroll-behavior: smooth;
}

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

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

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

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

/* ── Header ────────────────────────────────────────── */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(14px);
}

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

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

.logo-icon {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), #C0392B);
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 800;
    color: white;
    letter-spacing: -0.05em;
}

.logo-title {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

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

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    position: relative;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.icon-btn:hover {
    background: var(--border);
    color: var(--text);
}

.fav-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--accent);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    padding: 0 3px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none !important;
}

/* ── Main Layout ───────────────────────────────────── */
.main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 24px;
    align-items: start;
}

/* ── Sidebar ───────────────────────────────────────── */
.sidebar {
    position: sticky;
    top: 76px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.control-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.ctrl-textarea {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.83rem;
    line-height: 1.5;
    padding: 10px 12px;
    resize: vertical;
    outline: none;
    font-family: inherit;
    transition: border-color var(--transition);
}

.ctrl-textarea:focus {
    border-color: var(--accent);
}

.ctrl-range {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    cursor: pointer;
    outline: none;
}

.ctrl-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.2);
    transition: transform var(--transition);
}

.ctrl-range::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.separator {
    height: 1px;
    background: var(--border);
}

/* Chip groups */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.chip {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    font-size: 0.72rem;
    padding: 4px 11px;
    cursor: pointer;
    transition: all var(--transition);
}

.chip:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* BG toggle */
.bg-toggle-group {
    display: flex;
    gap: 5px;
}

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

.bg-btn.active {
    border-color: var(--accent);
    color: var(--accent);
}

.sidebar-stats {
    text-align: center;
}

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

/* ── Search Row ────────────────────────────────────── */
.search-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.88rem;
    padding: 10px 14px 10px 38px;
    outline: none;
    transition: border-color var(--transition);
}

.search-input:focus {
    border-color: var(--accent);
}

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

.btn-secondary {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.82rem;
    padding: 10px 16px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-secondary[aria-pressed="true"] {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(231, 76, 60, 0.08);
}

/* ── Pairings Grid ─────────────────────────────────── */
.pairings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

/* ── Pairing Card ──────────────────────────────────── */
.pairing-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    animation: card-in 0.35s ease both;
    display: flex;
    flex-direction: column;
}

.pairing-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: rgba(231, 76, 60, 0.3);
}

@keyframes card-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Preview area */
.card-preview {
    padding: 28px 24px 20px;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.card-preview.bg-white {
    background: #FFFFFF;
    color: #2C3E50;
}

.card-preview.bg-dark {
    background: #0F0F1A;
    color: #ECF0F1;
}

.card-preview.bg-warm {
    background: #FDF6EC;
    color: #3D2C1E;
}

.card-preview.bg-paper {
    background: #F5F0E8;
    color: #2C2C2C;
}

.preview-heading {
    line-height: 1.15;
    transition: font-size var(--transition), color var(--transition);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.preview-body {
    line-height: 1.65;
    transition: font-size var(--transition), color var(--transition);
    opacity: 0.82;
}

/* Card footer */
.card-footer {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card-names {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.font-name-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 9px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.font-name-badge .role {
    color: var(--accent);
    font-weight: 600;
    margin-right: 2px;
}

.font-pair-arrow {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.mood-tags {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.mood-tag {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(231, 76, 60, 0.1);
    color: var(--accent);
    border: 1px solid rgba(231, 76, 60, 0.25);
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
}

.card-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.72rem;
    padding: 6px 12px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
}

.card-btn:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.card-btn.fav-btn.active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(231, 76, 60, 0.08);
}

.card-btn.export-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* ── Empty State ───────────────────────────────────── */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
}

/* ── Modal ─────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 560px;
    box-shadow: var(--shadow);
    animation: modal-in 0.2s ease;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

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

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    line-height: 1;
    transition: color var(--transition);
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.tab {
    flex: 1;
    background: transparent;
    border: none;
    padding: 10px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition);
    border-right: 1px solid var(--border);
}

.tab:last-child {
    border-right: none;
}

.tab.active {
    background: var(--accent);
    color: white;
}

.tab:hover:not(.active) {
    background: var(--surface2);
}

.code-block {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.78rem;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-all;
    overflow: auto;
    max-height: 200px;
    line-height: 1.7;
}

.btn-primary {
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 10px 20px;
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition);
    align-self: flex-start;
}

.btn-primary:hover {
    background: #C0392B;
    box-shadow: 0 4px 14px rgba(231, 76, 60, 0.3);
}

/* ── Favorites Drawer ──────────────────────────────── */
.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 300;
    width: 360px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.2);
    animation: drawer-in 0.25s ease;
}

@keyframes drawer-in {
    from {
        transform: translateX(100%);
    }

    to {
        transform: none;
    }
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

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

.fav-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fav-item {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.fav-item-info {
    font-size: 0.82rem;
    color: var(--text);
    font-weight: 500;
}

.fav-item-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.fav-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    transition: color var(--transition);
}

.fav-remove:hover {
    color: var(--accent);
}

.drawer-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.82rem;
    padding: 8px 16px;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Backdrop */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 299;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
}

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

    .sidebar {
        position: static;
    }
}

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

    .pairings-grid {
        grid-template-columns: 1fr;
    }

    .drawer {
        width: 100%;
    }
}