/* ── base_components.css ─────────────────────────────────────────────────────
   Component styles for GearSwap AI base layout.
   CSS custom properties (:root / [data-theme]) remain inline in base.html
   for FOUC prevention — do NOT move them here.
   ─────────────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
* { font-family: var(--font-body); }
h1, .page-title, .stat-value, .brand-name { font-family: var(--font-display); }
h2, h3, h4, .card-header, .nav-link, .btn, label { font-family: var(--font-heading); }
code, pre, .badge, .mono, .vin, .stock-number, .price-value { font-family: var(--font-mono); }
body {
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── topbar ── */
.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(8,12,18,0.92);
}
.topbar-inner {
    display: flex;
    align-items: center;
    gap: 0;
    height: 56px;
    max-width: 100%;
}
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    flex-shrink: 0;
    margin-right: 12px;
}
.topbar-brand:hover { color: var(--text-primary); }
.brand-icon {
    width: 32px;
    height: 32px;
    background: var(--accent-soft);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* ── topbar-slot: dedicated centre-left zone for per-page injected actions
   (e.g. Back button). Grows to fill unused space so .topbar-actions stays
   pinned to the right and is never clipped. ── */
.topbar-slot {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    padding-left: 12px;
    min-width: 0;
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 0;
    min-width: 0;
}

/* ── page container ── */
.page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 48px;
}

/* ── card surface ── */
.card-surface {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

/* ── buttons ── */
.btn-accent {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 8px 18px;
    transition: all 0.15s;
}
.btn-accent:hover { background: var(--accent-hover); color: #fff; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 7px 14px;
    transition: all 0.15s;
}
.btn-ghost:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-danger-ghost {
    background: transparent;
    color: var(--red);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 7px 14px;
    transition: all 0.15s;
}
.btn-danger-ghost:hover {
    background: var(--red-soft);
    border-color: var(--red);
}

/* ── form inputs ── */
.input-modern {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input-modern:focus {
    background: var(--bg-primary);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px var(--accent-soft);
    outline: none;
}
.input-modern::placeholder { color: var(--text-muted); }

/* ── badges ── */
.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.badge-salvage { background: var(--red-soft); color: var(--red); }
.badge-wovr { background: var(--amber-soft); color: var(--amber); }
.badge-images { background: var(--accent-soft); color: var(--accent); }
.badge-green { background: var(--green-soft); color: var(--green); }

/* ── toast notifications ── */
.toast-container {
    position: fixed;
    top: 68px;
    right: 20px;
    z-index: 1050;
    max-width: 420px;
}
.toast-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    animation: slideIn 0.25s ease;
}
.toast-item.success { border-left: 3px solid var(--green); }
.toast-item.danger { border-left: 3px solid var(--red); }
.toast-item.warning { border-left: 3px solid var(--amber); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }

/* ── progress overlay ── */
.progress-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 2000;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0;
    margin: 0;
}
.progress-overlay.active { display: table; }
.progress-overlay-cell {
    display: table-cell;
    vertical-align: middle;
    text-align: center;
    padding: 20px;
}
.progress-panel {
    display: inline-block;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px 36px;
    width: 460px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 24px 48px rgba(0,0,0,0.5);
}
.progress-step-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    transition: background 0.3s;
}
.progress-step-icon.connecting { background: var(--accent-soft); }
.progress-step-icon.parsing { background: var(--green-soft); }
.progress-step-icon.downloading { background: var(--amber-soft); }
.progress-step-icon.saving { background: var(--green-soft); }
.progress-step-icon.done { background: var(--green); }
.progress-step-icon.error { background: var(--red); }
.progress-bar-track {
    background: var(--bg-elevated);
    border-radius: 100px;
    height: 6px;
    overflow: hidden;
    margin: 14px 0;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 100px;
    transition: width 0.4s ease;
    background: var(--accent);
    width: 0%;
}
.progress-bar-fill.error { background: var(--red); }
.progress-detail {
    color: var(--text-secondary);
    font-size: 0.85rem;
    min-height: 1.3em;
}
.progress-pct {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.85rem;
}
.progress-total-section {
    display: none;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}
.progress-total-section.visible { display: block; }
.progress-total-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.progress-total-label strong { color: var(--text-primary); font-weight: 600; }
.progress-total-bar {
    background: var(--bg-elevated);
    border-radius: 100px;
    height: 8px;
    overflow: hidden;
}
.progress-total-fill {
    height: 100%;
    border-radius: 100px;
    transition: width 0.5s ease;
    background: var(--green);
    width: 0%;
}
.progress-eta {
    display: none;
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.progress-eta.visible { display: flex; justify-content: center; align-items: center; gap: 6px; }
.progress-eta svg { flex-shrink: 0; }
.progress-log {
    margin-top: 14px;
    text-align: left;
    max-height: 80px;
    overflow-y: auto;
    font-size: 0.72rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
}
.progress-log::-webkit-scrollbar { width: 4px; }
.progress-log::-webkit-scrollbar-track { background: transparent; }
.progress-log::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
.progress-log div { padding: 1px 0; }
.progress-log div:last-child { color: var(--text-secondary); }

/* ── section title ── */
.section-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* ── topbar nav ── */
.topbar-nav-link {
    font-size: 0.8rem;
    padding: 6px 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    white-space: nowrap;
}
.topbar-nav-link svg { flex-shrink: 0; }
.topbar-username {
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 0 4px;
    white-space: nowrap;
}
.notif-badge {
    position: absolute;
    top: 0px;
    right: 0px;
    background: var(--red);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 700;
    min-width: 15px;
    height: 15px;
    border-radius: 100px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ── listing action bar ── */
.listing-action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 0;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

/* ── mobile menu button ── */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    padding: 6px 8px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.mobile-menu-btn:hover { background: var(--bg-elevated); color: var(--text-primary); }
.mobile-menu-btn .notif-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red);
}

/* ── nav desktop links ── */
.nav-links-desktop { display: flex; align-items: center; gap: 8px; flex: 1; }

/* ── nav dropdown ── */
.nav-dropdown {
    position: relative;
}
.nav-dropdown-trigger {
    cursor: pointer;
}
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    padding-top: 8px;
    min-width: 200px;
    z-index: 200;
}
.nav-dropdown-menu::before {
    content: '';
    position: absolute;
    top: 0;
    left: -10px;
    right: -10px;
    height: 10px;
}
.nav-dropdown-menu-inner {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 6px 0;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.nav-dropdown.open .nav-dropdown-menu,
.nav-dropdown:hover .nav-dropdown-menu {
    display: block;
}
.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}
.nav-dropdown-item:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}
.nav-dropdown-item svg { flex-shrink: 0; opacity: 0.6; }
.nav-dropdown-item:hover svg { opacity: 1; }
.nav-dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 12px;
}
.nav-dropdown-label {
    display: block;
    padding: 4px 14px 2px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    pointer-events: none;
}

/* ── product group pill ── */
.nav-product-group {
    display: flex;
    align-items: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
    flex-shrink: 0;
}
.nav-product-group .nav-dropdown-trigger,
.nav-product-group > a.topbar-nav-link {
    border-radius: 7px;
    padding: 4px 8px;
}
.nav-product-group .nav-dropdown-trigger:hover,
.nav-product-group > a.topbar-nav-link:hover,
.nav-product-group .nav-dropdown.open .nav-dropdown-trigger {
    background: var(--bg-card);
}
.nav-pill-sep {
    width: 1px;
    height: 18px;
    background: var(--border-color);
    flex-shrink: 0;
    margin: 0 1px;
}

/* ── nav spacer (pushes right-side utilities to the far right) ── */
.nav-spacer { flex: 1; }

/* ── topbar vertical divider ── */
.topbar-divider {
    width: 1px;
    height: 22px;
    background: var(--border-color);
    flex-shrink: 0;
    margin: 0 4px;
}

/* ── user pill ── */
.nav-user-pill { display: inline-flex; align-items: center; }
.nav-user-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 4px 8px 4px 5px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-family: var(--font-body);
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.nav-user-trigger:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}
.nav-user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}
.nav-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
}
.nav-dropdown-menu--right {
    left: auto;
    right: 0;
}
.dropdown-notif-badge {
    margin-left: auto;
    background: var(--red);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 100px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ── mobile menu overlay & panel ── */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 9998;
}
.mobile-menu-overlay.active { display: block; }

.mobile-menu-panel {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    z-index: 9999;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 0;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}
.mobile-menu-panel.active {
    display: block;
    transform: translateX(0);
}
.mobile-menu-header {
    padding: 0 20px 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.mobile-menu-header .menu-user {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}
.mobile-menu-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 1.4rem;
    line-height: 1;
}
.mobile-menu-close:hover { color: var(--text-primary); }
.mobile-menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
}
.mobile-menu-link:hover { background: var(--bg-elevated); color: var(--text-primary); }
.mobile-menu-link svg { flex-shrink: 0; opacity: 0.7; }
.mobile-menu-link .menu-badge {
    margin-left: auto;
    background: var(--red);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 100px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.mobile-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 20px;
}
.mobile-menu-section {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 12px 20px 4px;
}
.mobile-menu-link.danger { color: var(--red); }
.mobile-menu-link.danger:hover { background: var(--red-soft); }

/* ── mobile menu accordion (details/summary sections) ── */
.mmaccordion {
    border: none;
    padding: 0;
    margin: 0;
    display: block;
}
.mmaccordion > summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 20px;
    user-select: none;
    -webkit-user-select: none;
}
.mmaccordion > summary::-webkit-details-marker { display: none; }
.mmaccordion > summary::after {
    content: '›';
    font-size: 1rem;
    color: var(--text-muted);
    transition: transform 0.2s;
    transform: rotate(0deg);
    line-height: 1;
}
.mmaccordion[open] > summary::after {
    transform: rotate(90deg);
}

/* ── topbar-nav-text: visible label spans inside .topbar-nav-link buttons ── */
.topbar-nav-text {
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1;
    color: inherit;
}

/* ── responsive breakpoint ── */
@media (max-width: 1024px) {
    .nav-links-desktop { display: none; }
    .mobile-menu-btn { display: flex; align-items: center; }
    .topbar-brand span:last-child > span:last-child { display: none; }
    .topbar-nav-text { font-size: 0.75rem; }
}
