/*
 * Heavy Buddy — semantic theme variables.
 *
 * Default = light (Mascus-style: white surfaces, yellow brand, sober).
 * Override on <html data-theme="dark"> for the dark variant.
 *
 * Aliases at the bottom keep the legacy variable names working
 * (--orange, --dark, --darker...) so we don't have to grep through
 * every inline <style> block — they all inherit the new semantics.
 */

/* Roboto en self-host — aucune requête vers fonts.googleapis.com (RGPD). */
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/roboto/roboto-latin-400.b07da7aa3e4f.woff2") format('woff2');
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/roboto/roboto-latin-500.02e18aa1a344.woff2") format('woff2');
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/roboto/roboto-latin-700.47581e04640c.woff2") format('woff2');
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 900;
    font-display: swap;
    src: url("../fonts/roboto/roboto-latin-900.1b7363d64c4d.woff2") format('woff2');
}

:root {
    /* ── Surfaces ─────────────────────────── */
    --bg: #FFFFFF;
    --surface: #F7F7F8;
    --surface-2: #EDEEF1;

    /* ── Text ─────────────────────────────── */
    --text: #1A1D26;
    --text-muted: #5A6273;
    --text-subtle: #8B92A1;

    /* ── Borders ──────────────────────────── */
    --border: #E5E7EB;
    --border-strong: #CBD0DA;

    /* ── Brand (yellow primary) ───────────── */
    --primary: #FACC15;
    --primary-dark: #EAB308;
    --primary-text: #1A1D26;        /* dark text on yellow buttons */

    /* ── Status ───────────────────────────── */
    --success: #16A34A;
    --danger: #DC2626;
    --info: #2563EB;

    /* ── Effects ──────────────────────────── */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow: 0 4px 12px rgba(15, 23, 42, .08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);
    --radius: 8px;
    --radius-lg: 14px;
    --radius-pill: 9999px;

    /* ── Legacy aliases ───────────────────── */
    /* These existed before the theme refactor. Keep them mapped to
       the semantic vars so all the inline <style> blocks across the
       site keep working without grep-replace. */
    --orange: var(--primary);
    --orange-dark: var(--primary-dark);
    --dark: var(--surface);
    --darker: var(--bg);
    --gray: var(--border);
    --gray-light: var(--border-strong);
    --light: var(--text);
    --white: var(--text);
    --green: var(--success);
    --red: var(--danger);
    --blue: var(--info);
    --sidebar-w: 260px;
}

/* ── Dark theme overrides ─────────────────── */
[data-theme="dark"] {
    --bg: #080F1A;
    --surface: #0D1B2A;
    --surface-2: #1B2838;

    --text: #E8E8F0;
    --text-muted: #8888A0;
    --text-subtle: #55556A;

    --border: #1B2838;
    --border-strong: #2A3A4E;

    /* Same yellow looks fine on dark too */
    --primary: #FACC15;
    --primary-dark: #EAB308;
    --primary-text: #0D1B2A;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow: 0 4px 12px rgba(0, 0, 0, .5);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .6);

    /* Legacy aliases re-pointed to dark surfaces — note --light/--white
       deliberately stay 'text' so light text still reads on dark bg. */
    --orange: var(--primary);
    --orange-dark: var(--primary-dark);
    --dark: var(--surface);
    --darker: var(--bg);
    --gray: var(--border);
    --gray-light: var(--border-strong);
    --light: var(--text);
    --white: #FFFFFF;
    --green: var(--success);
    --red: var(--danger);
    --blue: var(--info);
}

/* Smooth color transitions when toggling themes */
html, body, header, main, section, aside, nav, footer, div, a, button,
input, textarea, select, table, td, th {
    transition: background-color .2s ease, color .15s ease, border-color .2s ease;
}

/* ── Shared login modal (in-page popup, AJAX-driven) ── */
/* Use !important on positioning so no page-level inline <style> can
   accidentally pull the modal back into the document flow. */
.hb-modal-overlay {
    display: none !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(8, 15, 26, .72) !important;
    backdrop-filter: blur(2px);
    z-index: 100000 !important;   /* above chat FAB (z-index 9999) */
    align-items: center !important;
    justify-content: center !important;
    padding: 16px;
    overflow-y: auto;
}
.hb-modal-overlay.active { display: flex !important; }
.hb-modal {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 24px 64px rgba(0, 0, 0, .35);
    margin: auto;
}
.hb-modal h2 {
    color: var(--text);
    margin: 0 0 22px;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 800;
}
.hb-modal label {
    display: block;
    color: var(--text-muted);
    font-size: .82rem;
    margin: 14px 0 6px;
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 600;
}
.hb-modal input[type="text"],
.hb-modal input[type="email"],
.hb-modal input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: .95rem;
    outline: none;
    transition: border-color .15s;
    font-family: inherit;
}
.hb-modal input:focus { border-color: var(--primary); }
.hb-modal-submit {
    width: 100%;
    margin-top: 22px;
    padding: 12px 18px;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: var(--primary-text);
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, transform .1s;
}
.hb-modal-submit:hover { background: var(--primary-dark); transform: translateY(-1px); }
.hb-modal-submit:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.hb-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
}
.hb-modal-close:hover { color: var(--text); text-decoration: none; }
.hb-modal-error {
    display: none;
    background: rgba(220, 38, 38, .08);
    border: 1px solid rgba(220, 38, 38, .35);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: .85rem;
    margin-bottom: 14px;
    text-align: left;
}
.hb-modal-foot {
    text-align: center;
    margin-top: 16px;
    color: var(--text-muted);
    font-size: .85rem;
}
.hb-modal-foot a {
    color: var(--primary-dark);
    font-weight: 600;
    text-decoration: none;
}
.hb-modal-foot a:hover { text-decoration: underline; }

/* ── Logo integration ──
   Two pre-processed PNG variants share the same dimensions and ship
   with a transparent backdrop, so the logo sits flush on the nav in
   either theme without any blend-mode trickery:
   - logo_hd.png       → white/yellow strokes (use on dark surfaces)
   - logo_hd_light.png → navy/yellow strokes (use on light surfaces)
   Default (light theme) swaps the <img> source via the CSS content property.
   Dark theme keeps the original file referenced in the markup. */
html:not([data-theme="dark"]) .logo img,
html:not([data-theme="dark"]) .sidebar-logo img {
    content: url("/static/images/logo_hd_light.9f90d2364f91.png");
}

/* ── Centered search bar in the header (used on /search/ and /ad/X/) ── */
.nav-with-center-search { gap: 24px; }
.nav-search-center {
    position: relative;
    flex: 1;
    max-width: 560px;
    margin: 0 12px;
}
.nav-search-center input {
    width: 100%;
    padding: 11px 16px 11px 40px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: .92rem;
    outline: none;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.nav-search-center input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(250, 204, 21, .15);
}
.nav-search-center svg {
    position: absolute;
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}
@media (max-width: 860px) {
    .nav-with-center-search .nav-search-center { display: none; }
}

/* ── Shared catalog filter sidebar (used on /search/ and /ad/<pk>/) ── */
.sidebar-search { position: relative; margin-bottom: 14px; }
.sidebar-search input {
    width: 100%;
    padding: 11px 14px 11px 38px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: .9rem;
    outline: none;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.sidebar-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(250, 204, 21, .15);
}
.sidebar-search svg {
    position: absolute;
    top: 50%;
    left: 13px;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}
.filters {
    position: sticky;
    top: 96px;
    max-height: calc(100vh - 112px);
    overflow-y: auto;
    padding-right: 6px;
}
.filters::-webkit-scrollbar { width: 6px; }
.filters::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.filter-section { border-bottom: 1px solid var(--border); padding: 14px 0 16px; }
.filter-section:first-child { padding-top: 0; }
.filter-section:last-child { border-bottom: none; }
.filter-section h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: .95rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 10px;
    cursor: pointer;
    user-select: none;
}
.filter-section h3 svg {
    width: 16px;
    height: 16px;
    transition: transform .2s;
    color: var(--text-muted);
}
.filter-section.collapsed h3 svg { transform: rotate(-90deg); }
.filter-section.collapsed .filter-body { display: none; }
.filter-body { display: block; }
.facet-search {
    width: 100%;
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: .82rem;
    outline: none;
    margin-bottom: 10px;
    font-family: inherit;
}
.facet-search:focus { border-color: var(--primary); }
.facet-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 240px;
    overflow-y: auto;
}
.facet-list::-webkit-scrollbar { width: 4px; }
.facet-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }
.facet-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    font-size: .85rem;
    color: var(--text);
    cursor: pointer;
    border-radius: 4px;
}
.facet-item:hover { background: var(--surface); }
.facet-item.zero { color: var(--text-subtle); cursor: not-allowed; }
.facet-item input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: inherit;
}
.facet-item .label { flex: 1; }
.facet-item .count { font-size: .78rem; color: var(--text-muted); }
.facet-clear {
    font-size: .76rem;
    color: var(--text-subtle);
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
    text-decoration: none;
}
.facet-clear:hover { color: var(--primary-dark); }
.range-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 6px;
    align-items: center;
}
.range-row input {
    width: 100%;
    padding: 7px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: .82rem;
    outline: none;
    text-align: center;
    font-family: inherit;
}
.range-row input:focus { border-color: var(--primary); }
.range-row span { color: var(--text-muted); font-size: .82rem; }
.filter-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    font-size: .88rem;
    color: var(--text);
    cursor: pointer;
}
.filter-toggle-row input { accent-color: var(--primary); width: 16px; height: 16px; }

/* ── Shared browse strip (Ritchie-Bros-style sticky category bandeau) ── */
.browse-strip {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 80px;
    z-index: 90;
}
.browse-strip-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 40px;
    display: flex;
    align-items: center;
    gap: 36px;
    height: 52px;
}
.browse-item { position: relative; display: inline-flex; }
.browse-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: .92rem;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: inherit;
    transition: color .15s;
    white-space: nowrap;
}
.browse-link:hover { color: var(--primary-dark); }
.bs-chevron { transition: transform .2s; }
.browse-item.open .bs-chevron { transform: rotate(180deg); }
.browse-item.open > .browse-link { color: var(--primary-dark); }
.browse-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 12px);
    left: -14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    padding: 8px 0;
    z-index: 110;
}
.browse-dropdown.wide {
    min-width: 480px;
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}
.browse-dropdown.active { display: block; }
.browse-dropdown.wide.active { display: grid; }
.browse-dropdown a {
    display: block;
    padding: 10px 18px;
    color: var(--text);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.browse-dropdown a:hover {
    background: var(--surface-2);
    color: var(--primary-dark);
}
@media (max-width: 768px) {
    .browse-strip { display: none; }
}

/* ── Theme toggle button (re-used in dashboard + public headers) ── */
.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color .2s, color .2s, background .2s;
}
.theme-toggle:hover {
    border-color: var(--primary);
    color: var(--primary-dark);
    background: rgba(250, 204, 21, .08);
}
.theme-toggle svg { width: 18px; height: 18px; }

/* Show sun in dark mode (to switch to light), moon in light mode */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
