/* ==========================================================================
   Dealership Boilerplate — Dark Theme + Theme Toggle Button
   Developer : Ben de Kooker
   Website   : http://dealership.local
   Email     : info@bdekooker.co.za
   Cell      : +27 76 481 8324

   Activated when <html data-theme="dark"> is set (by the FOUC script
   in default.php / admin.php). Overrides CSS custom properties and
   component styles for a premium dark look: near-black navy background
   with gold accents.
   ========================================================================== */

/* ========================================================================
   THEME TOGGLE BUTTON (works in both light + dark mode)
   ======================================================================== */
.theme-toggle {
    background: none;
    border: 1px solid var(--bdk-border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--bdk-transition);
    flex-shrink: 0;
    color: var(--bdk-navy);
    font-size: 1.1rem;
    line-height: 1;
}
.theme-toggle:hover {
    background: var(--bdk-cream);
    border-color: var(--bdk-gold);
    color: var(--bdk-gold);
    transform: scale(1.05);
}
.theme-toggle .icon-moon { display: inline-block; }
.theme-toggle .icon-sun  { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: inline-block; }

/* Admin topbar variant — smaller */
.admin-topbar .theme-toggle {
    width: 36px;
    height: 36px;
    font-size: 1rem;
    border-color: var(--bdk-border);
}

/* Smooth transition when switching themes */
body, .navbar-premium, .top-contact-bar, .card-premium, .vehicle-card,
.filter-card, .admin-topbar, .admin-sidebar, .admin-content, .admin-footer,
.footer-premium, .page-hero, .stats-section, .cta-band, .brand-strip,
.trust-strip, .section, .form-control, .form-select, .input-group-text,
.alert, .table, .dropdown-menu, .auth-card, .card, .btn-outline-secondary {
    transition: background-color .35s ease, color .35s ease, border-color .35s ease;
}

/* ========================================================================
   DARK MODE OVERRIDES
   ======================================================================== */
[data-theme="dark"] {

    /* ----- Override CSS custom properties ----- */
    --bdk-cream:       #0d1117;
    --bdk-cream-dark:  #161b22;
    --bdk-charcoal:    #e6edf3;
    --bdk-slate:       #8b949e;
    --bdk-slate-light: #6e7681;
    --bdk-white:       #161b22;
    --bdk-border:      #30363d;
    --bdk-navy-text:   #58a6ff;

    --bdk-shadow-sm:   0 2px 8px rgba(0, 0, 0, 0.3);
    --bdk-shadow:      0 6px 24px rgba(0, 0, 0, 0.4);
    --bdk-shadow-lg:   0 16px 48px rgba(0, 0, 0, 0.5);

    /* ----- Body ----- */
    body {
        background: #0d1117;
        color: #e6edf3;
    }

    h1, h2, h3, h4, h5, h6,
    .h1, .h2, .h3, .h4, .h5, .h6 {
        color: #f0f6fc;
    }

    a:not(.btn) { color: var(--bdk-gold); }
    a:not(.btn):hover { color: var(--bdk-gold-light); }

    .text-navy { color: #58a6ff !important; }
    .text-muted { color: #8b949e !important; }
    .text-slate { color: #8b949e !important; }
    .text-dark { color: #e6edf3 !important; }

    /* ----- Navbar ----- */
    .navbar-premium {
        background: rgba(13, 17, 23, 0.92) !important;
        border-bottom: 1px solid #30363d;
    }
    .navbar-premium.scrolled {
        background: rgba(13, 17, 23, 0.98) !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    }
    .navbar-premium .navbar-brand { color: #f0f6fc !important; }
    .navbar-premium .nav-link { color: #c9d1d9 !important; }
    .navbar-premium .nav-link:hover,
    .navbar-premium .nav-link.active { color: var(--bdk-gold) !important; }

    .navbar-premium .nav-link:hover { background: rgba(255, 255, 255, 0.04); }

    /* FIX: Navbar hamburger icon — Bootstrap uses a dark SVG that's
       invisible on the dark navbar. Override with a light SVG. */
    .navbar-premium .navbar-toggler-icon {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(255,255,255,0.85)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    }
    .navbar-premium .navbar-toggler {
        border-color: rgba(255, 255, 255, 0.15);
    }
    .navbar-premium .navbar-toggler:focus {
        box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.25);
    }

    /* FIX: Brand icon tile — navy gradient blends into dark navbar.
       Add a gold border + glow so the tile is visible. */
    .navbar-premium .navbar-brand .brand-icon {
        background: linear-gradient(135deg, #1a3a5c 0%, #0d2540 100%);
        border: 1px solid rgba(212, 175, 55, 0.35);
        box-shadow: 0 0 12px rgba(212, 175, 55, 0.15);
    }

    /* FIX: Theme toggle button — dark navy color is invisible on the
       dark navbar. Use a light color instead. */
    .theme-toggle {
        color: #c9d1d9;
        border-color: #30363d;
    }
    .theme-toggle:hover {
        color: var(--bdk-gold);
        border-color: var(--bdk-gold);
        background: rgba(212, 175, 55, 0.08);
    }

    /* ----- Top contact bar ----- */
    .top-contact-bar {
        background: #010409;
        border-bottom-color: rgba(212, 175, 55, 0.1);
    }

    /* ----- Hero ----- */
    .hero-premium { background: #010409; }

    /* FIX: Hero overlay — the original overlay was too dark on top of
       the #010409 background. Lighten it significantly so the hero
       image is still visible while keeping text readable. */
    .hero-premium .hero-overlay {
        background:
            linear-gradient(135deg, rgba(8, 37, 68, 0.65) 0%, rgba(8, 37, 68, 0.35) 50%, rgba(8, 37, 68, 0.2) 100%),
            linear-gradient(180deg, rgba(5, 26, 54, 0.1) 0%, rgba(5, 26, 54, 0.6) 100%);
    }

    /* FIX: Hero CTA outline button — make the border brighter so it's
       clearly visible against the dark hero. */
    .hero-premium .btn-outline-light {
        border-color: rgba(255, 255, 255, 0.6);
    }
    .hero-premium .btn-outline-light:hover {
        background: rgba(255, 255, 255, 0.12);
        border-color: #fff;
    }

    /* ----- Trust strip ----- */
    .trust-strip {
        background: #0d1117;
        border-bottom-color: #30363d;
    }
    .trust-item .trust-icon {
        background: rgba(212, 175, 55, 0.12);
    }
    .trust-item .trust-title { color: #f0f6fc; }
    .trust-item .trust-text { color: #8b949e; }

    /* ----- Vehicle cards ----- */
    .vehicle-card {
        background: #161b22;
        border-color: #30363d;
    }
    .vehicle-card:hover {
        border-color: rgba(212, 175, 55, 0.4);
    }
    .vehicle-card .vehicle-title { color: #f0f6fc; }
    .vehicle-card .vehicle-title a { color: #f0f6fc; }
    .vehicle-card .vehicle-title a:hover { color: var(--bdk-gold); }
    .vehicle-card .vehicle-specs {
        border-top-color: #30363d;
        border-bottom-color: #30363d;
        color: #8b949e;
    }
    .vehicle-card .vehicle-price { color: var(--bdk-gold); }
    .vehicle-card .vehicle-price-label { color: #8b949e; }
    .vehicle-card .btn-view {
        background: #58a6ff;
        color: #fff;
    }
    .vehicle-card .btn-view:hover {
        background: var(--bdk-gold);
        color: #0d1117;
    }
    .vehicle-card .vehicle-image-wrap { background: #0d1117; }
    .vehicle-card .badge-status {
        background: rgba(22, 27, 34, 0.95);
        color: #e6edf3;
    }

    /* ----- Stats section ----- */
    .stats-section {
        border-top: 1px solid #30363d;
        border-bottom: 1px solid #30363d;
    }

    /* ----- Testimonials ----- */
    .testimonial-card {
        background: #161b22;
        border-color: #30363d;
    }
    .testimonial-card .testimonial-text { color: #c9d1d9; }
    .testimonial-card .author-name { color: #f0f6fc; }
    .testimonial-card .author-meta { color: #8b949e; }
    .testimonial-card .author-avatar {
        background: linear-gradient(135deg, #58a6ff, #1f6feb);
    }

    /* ----- Brand strip ----- */
    .brand-strip {
        background: #0d1117;
        border-top-color: #30363d;
        border-bottom-color: #30363d;
    }
    .brand-strip .brand-logo { color: #484f58; }
    .brand-strip .brand-logo:hover { color: var(--bdk-gold); }

    /* ----- CTA band (already dark — stays) ----- */

    /* ----- Page hero (already dark — add border) ----- */
    .page-hero {
        border-bottom: 1px solid #30363d;
    }

    /* ----- Section backgrounds ----- */
    .bg-cream { background-color: #0d1117 !important; }
    .bg-light { background-color: #0d1117 !important; }
    .bg-white { background-color: #161b22 !important; }

    .section-eyebrow { color: var(--bdk-gold); }
    .section-subtitle { color: #8b949e; }
    .divider-gold { background: linear-gradient(90deg, var(--bdk-gold), var(--bdk-gold-light)); }

    /* ----- Filter card ----- */
    .filter-card {
        background: #161b22;
        border-color: #30363d;
    }
    .filter-card .form-label { color: #c9d1d9; }
    .filter-card .form-control,
    .filter-card .form-select {
        background: #0d1117;
        border-color: #30363d;
        color: #e6edf3;
    }
    .filter-card .form-control::placeholder { color: #484f58; }
    .filter-card .form-control:focus,
    .filter-card .form-select:focus {
        border-color: var(--bdk-gold);
        background: #0d1117;
        color: #e6edf3;
    }

    /* ----- Premium cards (generic) ----- */
    .card-premium {
        background: #161b22;
        border-color: #30363d;
    }
    .card-premium .card-icon {
        background: rgba(212, 175, 55, 0.12);
    }

    /* ----- Vehicle details ----- */
    .detail-gallery-main { background: #0d1117; }
    .detail-gallery-thumbs img {
        border-color: #30363d;
    }
    .detail-gallery-thumbs img:hover { border-color: var(--bdk-gold); }
    .detail-price-card {
        background: linear-gradient(135deg, rgba(212, 175, 55, 0.08) 0%, rgba(212, 175, 55, 0.02) 100%);
        border-color: rgba(212, 175, 55, 0.2);
    }
    .detail-price-card .price-value { color: var(--bdk-gold); }
    .detail-price-card .price-label { color: #8b949e; }
    .detail-spec-row { border-bottom-color: #30363d; }
    .detail-spec-row .spec-label { color: #8b949e; }
    .detail-spec-row .spec-value { color: #e6edf3; }

    /* ----- Forms ----- */
    .form-premium .form-label { color: #c9d1d9; }
    .form-premium .form-control,
    .form-premium .form-select {
        background: #0d1117;
        border-color: #30363d;
        color: #e6edf3;
    }
    .form-premium .form-control::placeholder { color: #484f58; }
    .form-premium .form-control:focus,
    .form-premium .form-select:focus {
        border-color: var(--bdk-gold);
        background: #0d1117;
        color: #e6edf3;
    }
    .form-premium .input-group-text {
        background: #161b22;
        border-color: #30363d;
        color: #8b949e;
    }

    /* ----- Alerts ----- */
    .alert-success { background: #0d2818; color: #56d364; }
    .alert-danger  { background: #2d0b0e; color: #f85149; }
    .alert-warning { background: #2d2300; color: #d29922; }
    .alert-info    { background: #0c2233; color: #58a6ff; }
    .alert .btn-close { filter: invert(1) grayscale(1) brightness(2); }

    /* ----- Pagination ----- */
    .pagination .page-link {
        background: #161b22;
        border-color: #30363d;
        color: #c9d1d9;
    }
    .pagination .page-link:hover {
        background: #30363d;
        color: var(--bdk-gold);
    }
    .pagination .page-item.active .page-link {
        background: var(--bdk-navy);
        border-color: var(--bdk-navy);
        color: #fff;
    }
    .pagination .page-item.disabled .page-link {
        background: #0d1117;
        color: #484f58;
    }

    /* ----- Footer ----- */
    .footer-premium { border-top-color: rgba(212, 175, 55, 0.15); }

    /* ----- Auth pages ----- */
    .auth-card {
        background: #161b22;
        border-color: #30363d;
    }
    .auth-card h1 { color: #f0f6fc; }
    .auth-card .form-label { color: #c9d1d9; }
    .auth-card .form-control {
        background: #0d1117;
        border-color: #30363d;
        color: #e6edf3;
    }
    .auth-card .form-control::placeholder { color: #484f58; }
    .auth-card .form-control:focus {
        border-color: var(--bdk-gold);
        background: #0d1117;
        color: #e6edf3;
    }
    .auth-card .input-group-text {
        background: #21262d;
        border-color: #30363d;
        color: #8b949e;
    }

    /* ----- Breadcrumb ----- */
    .breadcrumb-premium {
        background: #0d1117;
        border-bottom-color: #30363d;
    }
    .breadcrumb-premium .breadcrumb a { color: var(--bdk-gold); }
    .breadcrumb-premium .breadcrumb-item.active { color: #8b949e; }

    /* ----- Back to top ----- */
    #backToTop {
        background: #161b22;
        border: 1px solid #30363d;
        color: var(--bdk-gold);
    }
    #backToTop:hover {
        background: var(--bdk-gold);
        color: #0d1117;
    }

    /* ----- PWA install banner (already dark — stays) ----- */

    /* ----- Captcha question chip ----- */
    .captcha-question {
        background: rgba(212, 175, 55, 0.12) !important;
        color: var(--bdk-gold) !important;
        border-color: #30363d !important;
    }

    /* ----- Dropdown menus ----- */
    .dropdown-menu {
        background: #161b22;
        border-color: #30363d;
    }
    .dropdown-item { color: #c9d1d9; }
    .dropdown-item:hover, .dropdown-item:focus {
        background: #30363d;
        color: #f0f6fc;
    }
    .dropdown-item.text-danger:hover { background: rgba(248, 81, 73, 0.15); }
    .dropdown-divider { border-color: #30363d; }
    .dropdown-item-text { color: #8b949e; }

    /* ----- Modal ----- */
    .modal-content {
        background: #161b22;
        border-color: #30363d;
    }
    .modal-header { border-bottom-color: #30363d; }
    .modal-footer { border-top-color: #30363d; }
    .modal-title { color: #f0f6fc; }
    .btn-close { filter: invert(1) grayscale(1) brightness(2); }

    /* ========================================================================
       ADMIN PANEL DARK MODE
       ======================================================================== */
    .admin-topbar {
        background: #161b22;
        border-bottom-color: #30363d;
    }
    .admin-topbar .text-muted { color: #8b949e !important; }
    .admin-page-title { color: #f0f6fc; }
    .admin-hamburger {
        border-color: #30363d;
        color: #c9d1d9;
    }
    .admin-hamburger:hover { background: #21262d; }

    .admin-content { background: transparent; }
    .admin-footer {
        background: #161b22;
        border-top-color: #30363d;
        color: #8b949e;
    }

    /* Admin cards */
    .admin-content .card {
        background: #161b22;
        border-color: #30363d;
        color: #e6edf3;
    }
    .admin-content .card-header {
        background: #21262d;
        border-bottom-color: #30363d;
    }
    .admin-content .card-body { color: #e6edf3; }

    /* Admin stat cards */
    .stat-card {
        background: #161b22;
        border-color: #30363d;
    }
    .stat-card .text-muted { color: #8b949e !important; }
    .stat-card .text-primary { color: var(--bdk-gold) !important; }
    .stat-card .text-info { color: #58a6ff !important; }
    .stat-card .text-success { color: #56d364 !important; }
    .stat-card .display-6 { color: #f0f6fc; }

    /* Admin tables */
    .admin-content .table { color: #e6edf3; }
    .admin-content .table > :not(caption) > * > * {
        background-color: transparent;
        color: #e6edf3;
        border-bottom-color: #30363d;
    }
    .admin-content .table thead th {
        background: #21262d;
        color: #c9d1d9;
        border-bottom-color: #30363d;
    }
    .admin-content .table tbody tr:hover {
        background: rgba(255, 255, 255, 0.03);
    }
    .admin-content .table-light th {
        background: #21262d !important;
        color: #c9d1d9 !important;
        border-color: #30363d !important;
    }

    /* Admin forms */
    .admin-content .form-control,
    .admin-content .form-select {
        background: #0d1117;
        border-color: #30363d;
        color: #e6edf3;
    }
    .admin-content .form-control::placeholder { color: #484f58; }
    .admin-content .form-control:focus,
    .admin-content .form-select:focus {
        border-color: var(--bdk-gold);
        background: #0d1117;
        color: #e6edf3;
    }
    .admin-content .form-label { color: #c9d1d9; }
    .admin-content .input-group-text {
        background: #21262d;
        border-color: #30363d;
        color: #8b949e;
    }
    .admin-content .form-check-label { color: #e6edf3; }

    /* Admin nav pills */
    .admin-content .nav-pills .nav-link {
        color: #8b949e;
        background: transparent;
    }
    .admin-content .nav-pills .nav-link:hover {
        color: #e6edf3;
        background: rgba(255, 255, 255, 0.04);
    }
    .admin-content .nav-pills .nav-link.active {
        background: var(--bdk-navy);
        color: #fff;
    }

    /* Admin badges */
    .admin-content .badge.bg-secondary { background: #30363d !important; }
    .admin-content .badge.bg-success { background: #1a7f37 !important; }
    .admin-content .badge.bg-warning { background: #9e6a00 !important; color: #fff !important; }
    .admin-content .badge.bg-danger { background: #da3633 !important; }
    .admin-content .badge.bg-info { background: #1f6feb !important; }
    .admin-content .badge.bg-primary { background: #1f6feb !important; }
    .admin-content .badge.bg-light {
        background: #21262d !important;
        color: #c9d1d9 !important;
    }

    /* Admin list groups */
    .admin-content .list-group-item {
        background: #161b22;
        border-color: #30363d;
        color: #e6edf3;
    }
    .admin-content .list-group-item .text-muted { color: #8b949e !important; }

    /* Admin buttons */
    .admin-content .btn-outline-secondary {
        color: #8b949e;
        border-color: #30363d;
    }
    .admin-content .btn-outline-secondary:hover {
        background: #30363d;
        color: #fff;
    }
    .admin-content .btn-outline-danger {
        color: #f85149;
        border-color: rgba(248, 81, 73, 0.4);
    }
    .admin-content .btn-outline-danger:hover {
        background: rgba(248, 81, 73, 0.15);
        color: #f85149;
    }
    .admin-content .btn-outline-primary {
        color: #58a6ff;
        border-color: rgba(88, 166, 255, 0.4);
    }
    .admin-content .btn-outline-primary:hover {
        background: rgba(88, 166, 255, 0.15);
        color: #58a6ff;
    }
    .admin-content .btn-outline-success {
        color: #56d364;
        border-color: rgba(86, 211, 100, 0.4);
    }
    .admin-content .btn-outline-success:hover {
        background: rgba(86, 211, 100, 0.15);
        color: #56d364;
    }

    /* Admin text helpers */
    .admin-content .text-muted { color: #8b949e !important; }
    .admin-content .text-danger { color: #f85149 !important; }
    .admin-content .text-success { color: #56d364 !important; }
    .admin-content .fw-semibold { color: #f0f6fc; }
    .admin-content hr { border-color: #30363d; }
    .admin-content .border-top { border-top-color: #30363d !important; }
    .admin-content .border-bottom { border-bottom-color: #30363d !important; }

    /* Admin settings — color picker text inputs */
    .admin-content input[readonly] {
        background: #0d1117 !important;
        color: #8b949e !important;
    }

    /* Admin table thumb images */
    .admin-content .thumb { background: #0d1117; }

    /* Scrollbar */
    ::-webkit-scrollbar-track { background: #0d1117; }
    ::-webkit-scrollbar-thumb {
        background: #30363d;
        border-color: #0d1117;
    }
    ::-webkit-scrollbar-thumb:hover { background: #484f58; }

    /* Selection */
    ::selection { background: var(--bdk-gold); color: #0d1117; }
}

/* ========================================================================
   DARK MODE — MOBILE OVERRIDES
   ======================================================================== */
@media (max-width: 991.98px) {
    [data-theme="dark"] .navbar-premium .navbar-collapse {
        background: #161b22;
        border-color: #30363d;
    }
    [data-theme="dark"] .navbar-premium .nav-link:hover {
        background: rgba(255, 255, 255, 0.04);
    }
}