/* ════════════════════════════════════════════════════════════════
   BUILDFORWHO — HISTORY SIDEBAR STYLES
   Pure frontend feature, matches existing dark luxury palette
════════════════════════════════════════════════════════════════ */

/* ── History toggle button ─────────────────────────────────────── */
.history-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface, #1c1c17);
    border: 1px solid var(--border, rgba(255,255,255,0.07));
    border-radius: 10px;
    color: var(--white-dim, rgba(245,244,239,0.55));
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    transition: all 0.25s ease;
    margin-bottom: 20px;
    position: relative;
}

.history-toggle-btn:hover {
    border-color: var(--border-accent, rgba(234,179,8,0.25));
    color: var(--gold, #eab308);
    background: var(--surface-2, #242420);
    transform: translateY(-1px);
}

.history-toggle-btn i {
    font-size: 14px;
    color: var(--gold, #eab308);
}

.history-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gold, #eab308);
    color: #0a0a08;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1;
    margin-left: 2px;
    flex-shrink: 0;
}

/* ── Overlay ───────────────────────────────────────────────────── */
.history-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 1998;
    pointer-events: none;
    transition: background 0.3s ease;
}

.history-overlay.active {
    background: rgba(0, 0, 0, 0.6);
    pointer-events: all;
    backdrop-filter: blur(3px);
}

/* ── Sidebar ───────────────────────────────────────────────────── */
.history-sidebar {
    position: fixed;
    top: 0;
    left: -380px;
    width: 360px;
    height: 100vh;
    background: var(--bg-2, #111110);
    border-right: 1px solid var(--border, rgba(255,255,255,0.07));
    z-index: 1999;
    display: flex;
    flex-direction: column;
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.history-sidebar.open {
    left: 0;
}

@media (max-width: 480px) {
    .history-sidebar {
        width: 100vw;
        left: -100vw;
    }
}

/* ── Sidebar header ────────────────────────────────────────────── */
.history-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.07));
    flex-shrink: 0;
    background: var(--surface, #1c1c17);
}

.history-sidebar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Syne', 'Outfit', sans-serif;
    font-size: 17px;
    font-weight: 700;
    color: var(--white, #f5f4ef);
}

.history-sidebar-title i {
    color: var(--gold, #eab308);
    font-size: 16px;
}

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

.history-clear-btn,
.history-close-btn {
    background: transparent;
    border: 1px solid var(--border, rgba(255,255,255,0.07));
    color: var(--white-muted, rgba(245,244,239,0.3));
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.2s ease;
}

.history-clear-btn:hover {
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
    background: rgba(239, 68, 68, 0.08);
}

.history-close-btn:hover {
    border-color: var(--border-accent, rgba(234,179,8,0.25));
    color: var(--gold, #eab308);
}

/* ── Search ────────────────────────────────────────────────────── */
.history-search-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.07));
    flex-shrink: 0;
    background: var(--bg-2, #111110);
}

.history-search-wrap i {
    color: var(--white-muted, rgba(245,244,239,0.3));
    font-size: 13px;
    flex-shrink: 0;
}

.history-search-wrap input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--white, #f5f4ef);
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    outline: none;
    min-width: 0;
}

.history-search-wrap input::placeholder {
    color: var(--white-muted, rgba(245,244,239,0.3));
}

/* ── History list ──────────────────────────────────────────────── */
.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--gold, #eab308) transparent;
}

.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-thumb { background: var(--gold, #eab308); border-radius: 2px; }
.history-list::-webkit-scrollbar-track { background: transparent; }

/* ── Empty state ───────────────────────────────────────────────── */
.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    gap: 8px;
}

.history-empty i {
    font-size: 36px;
    color: var(--white-muted, rgba(245,244,239,0.3));
    margin-bottom: 8px;
    opacity: 0.4;
}

.history-empty p {
    font-size: 15px;
    font-weight: 600;
    color: var(--white-dim, rgba(245,244,239,0.55));
}

.history-empty span {
    font-size: 12px;
    color: var(--white-muted, rgba(245,244,239,0.3));
}

/* ── History item ──────────────────────────────────────────────── */
.history-item {
    background: var(--surface, #1c1c17);
    border: 1px solid var(--border, rgba(255,255,255,0.07));
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.history-item:hover {
    border-color: var(--border-accent, rgba(234,179,8,0.25));
    background: var(--surface-2, #242420);
    transform: translateX(3px);
}

.history-item:last-child { margin-bottom: 0; }

.history-item-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.history-item-idea {
    font-size: 13px;
    font-weight: 600;
    color: var(--white, #f5f4ef);
    line-height: 1.45;
    flex: 1;
}

.history-delete-btn {
    background: transparent;
    border: none;
    color: var(--white-muted, rgba(245,244,239,0.3));
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 11px;
    flex-shrink: 0;
    opacity: 0;
    transition: all 0.2s ease;
    line-height: 1;
}

.history-item:hover .history-delete-btn { opacity: 1; }

.history-delete-btn:hover {
    color: #f87171;
    background: rgba(239, 68, 68, 0.12);
}

.history-item-meta {
    margin-bottom: 8px;
}

.history-date {
    font-size: 11px;
    color: var(--white-muted, rgba(245,244,239,0.3));
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: 'JetBrains Mono', monospace;
}

.history-date i { font-size: 9px; }

.history-item-stats {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.history-verdict-badge {
    font-size: 9px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    padding: 2px 7px;
    border-radius: 8px;
    border: 1px solid;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.history-stat {
    font-size: 11px;
    color: var(--white-muted, rgba(245,244,239,0.3));
    display: flex;
    align-items: center;
    gap: 3px;
    font-family: 'JetBrains Mono', monospace;
}

.history-stat i {
    font-size: 9px;
    color: var(--gold, #eab308);
    opacity: 0.7;
}

.history-score {
    color: var(--gold, #eab308) !important;
    font-weight: 700;
}

/* ── History view banner ───────────────────────────────────────── */
.history-view-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, rgba(234,179,8,0.1), rgba(234,179,8,0.05));
    border: 1px solid var(--border-accent, rgba(234,179,8,0.25));
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
    animation: slideInDown 0.35s ease-out;
}

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

.history-banner-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.history-banner-left > i {
    font-size: 18px;
    color: var(--gold, #eab308);
    flex-shrink: 0;
}

.history-banner-left strong {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--white, #f5f4ef);
    margin-bottom: 2px;
}

.history-banner-left span {
    font-size: 11px;
    color: var(--white-muted, rgba(245,244,239,0.3));
    font-family: 'JetBrains Mono', monospace;
}

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

.history-rerun-btn {
    background: var(--gold, #eab308);
    color: #0a0a08;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Outfit', sans-serif;
    transition: all 0.2s ease;
}

.history-rerun-btn:hover {
    background: var(--gold-light, #fde047);
    transform: translateY(-1px);
}

.history-banner-close {
    background: transparent;
    border: 1px solid var(--border, rgba(255,255,255,0.07));
    color: var(--white-muted, rgba(245,244,239,0.3));
    width: 30px;
    height: 30px;
    border-radius: 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
}

.history-banner-close:hover {
    border-color: rgba(239,68,68,0.3);
    color: #f87171;
}

/* ── Comparison panel ──────────────────────────────────────────── */
.comparison-panel {
    background: var(--surface, #1c1c17);
    border: 1px solid var(--border-accent, rgba(234,179,8,0.25));
    border-radius: 14px;
    padding: 0;
    margin-bottom: 24px;
    overflow: hidden;
    animation: slideInDown 0.4s ease-out;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

.cmp-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.07));
    flex-wrap: wrap;
    background: linear-gradient(135deg, rgba(234,179,8,0.08), rgba(234,179,8,0.03));
}

.cmp-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Syne', 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--white, #f5f4ef);
    flex: 1;
}

.cmp-title i { color: var(--gold, #eab308); }

.cmp-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--white-muted, rgba(245,244,239,0.3));
    font-family: 'JetBrains Mono', monospace;
}

.cmp-date-sep {
    color: var(--gold, #eab308);
    font-weight: 700;
}

.cmp-close {
    background: transparent;
    border: 1px solid var(--border, rgba(255,255,255,0.07));
    color: var(--white-muted, rgba(245,244,239,0.3));
    width: 28px;
    height: 28px;
    border-radius: 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.cmp-close:hover {
    border-color: rgba(239,68,68,0.3);
    color: #f87171;
}

.cmp-verdict-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.07));
    font-size: 13px;
}

.cmp-verdict-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--white-muted, rgba(245,244,239,0.3));
    min-width: 120px;
}

.cmp-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0;
    padding: 0;
}

.cmp-metric {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.07));
    border-right: 1px solid var(--border, rgba(255,255,255,0.07));
    transition: background 0.2s ease;
}

.cmp-metric:last-child { border-bottom: none; }
.cmp-metric.cmp-changed { background: rgba(234,179,8,0.04); }

.cmp-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--white-muted, rgba(245,244,239,0.3));
    display: block;
    margin-bottom: 7px;
}

.cmp-values {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
}

.cmp-old {
    color: var(--white-muted, rgba(245,244,239,0.3));
    font-size: 12px;
}

.cmp-arrow {
    color: var(--white-muted, rgba(245,244,239,0.3));
    font-size: 11px;
}

.cmp-new {
    color: var(--white, #f5f4ef);
    font-weight: 700;
}

/* Diff indicators */
.diff-up   { color: #4ade80; font-weight: 700; font-size: 12px; }
.diff-down { color: #f87171; font-weight: 700; font-size: 12px; }
.diff-same { color: var(--white-muted, rgba(245,244,239,0.3)); font-size: 12px; }
.diff-na   { color: var(--white-muted, rgba(245,244,239,0.3)); font-size: 12px; }

.cmp-insight {
    padding: 14px 20px;
    background: rgba(234,179,8,0.05);
    border-top: 1px solid var(--border, rgba(255,255,255,0.07));
    font-size: 13px;
    color: var(--white-dim, rgba(245,244,239,0.55));
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.6;
}

.cmp-insight i {
    color: var(--gold, #eab308);
    flex-shrink: 0;
    margin-top: 2px;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .history-view-banner {
        flex-direction: column;
        align-items: flex-start;
    }

    .history-banner-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .cmp-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .cmp-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .cmp-metrics-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .cmp-metrics-grid {
        grid-template-columns: 1fr;
    }

    .history-toggle-btn span:not(.history-badge) {
        display: none;
    }
}
