/* Night mode (frontend). Switched on by the moon button (frontend/layouts/partials/header.blade.php), which sets
   class "theme-dark" and data-bs-theme="dark" on <html>. Loaded by frontend/layouts/app1.blade.php.

   Approach: the theme paints many surfaces white and sets dark text on them, so night mode
   1. makes every element transparent and gives all text one light colour, letting the dark page show through;
   2. gives the real surfaces (cards, forms, menus, dropdowns, modals) an explicit dark panel colour;
   3. leaves buttons, badges, images, the cart badge and the footer as designed. */

:root { --night-bg: #0c1221; --night-panel: #141d30; --night-line: #26324a; --night-text: #e4e9f3; --night-muted: #9aa6bd; }

/* ---- header toggle button ---- */
/* same size, fill and spacing as the cart button next to it (a.desk-cart in the header partial) */
.theme-toggle {
    width: 44px; height: 44px; border-radius: 50%; margin: 0 10px 0 0;
    border: 0; background: #eef2ff; color: #1e3a8a;
    display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
    font-size: 18px; line-height: 1; padding: 0; cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.theme-toggle:hover, .theme-toggle:focus-visible { background: #dbe4ff; outline: none; }
#navigation .nav-menu-social > li:has(> .theme-toggle) { display: inline-flex; align-items: center; }

/* night: toggle and cart are one matching pair */
html.theme-dark body #navigation .theme-toggle,
html.theme-dark body #navigation .nav-menu-social > li > a.desk-cart {
    background: #1c2740 !important; color: #e4e9f3 !important; border: 1px solid #2c3852 !important;
}
html.theme-dark body #navigation .theme-toggle:hover,
html.theme-dark body #navigation .nav-menu-social > li > a.desk-cart:hover { background: #243252 !important; }
html.theme-dark body #navigation .theme-toggle .theme-toggle-icon { color: #fbbf24 !important; }

/* ---- 1. base: transparent surfaces, one light text colour ---- */
html.theme-dark { color-scheme: dark; }
html.theme-dark body { background-color: var(--night-bg) !important; color: var(--night-text) !important; }

/* :where() keeps this rule's specificity at (0,1,1) so the panel rules below always win over it */
html.theme-dark :where(*:not(.btn, .btn *, .badge, .badge *, .label, .nws-button, .nws-button *, .join-btn, .join-btn *,
        .become-tutor, .become-tutor *, .desk-cart, .desk-cart *, .theme-toggle, .theme-toggle *, img, svg, svg *,
        .wb-cert, .wb-cert *, .dark-footer, .dark-footer *, .mnav-btn, .mnav-btn *, .progress-bar,
        .bg-main, .bg-primary, .bg-success, .bg-warning, .bg-danger, .bg-info, .bg-dark, .bg-green,
        .video-play-button, .video-play-button *, .wa-float, .wa-float *, .search-course-btn, .search-course-btn *,
        .nav-toggle, .course-buybar .btn)) {
    background-color: transparent !important;
    color: var(--night-text) !important;
    border-color: var(--night-line) !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

/* brand-coloured blocks keep their colour; their text stays light */
html.theme-dark :is(.bg-main, .bg-primary, .bg-dark) *:not(.btn, .btn *) { color: #fff !important; }

/* light backgrounds the theme forces with !important, IDs or inline gradients */
html.theme-dark body #latest-area,
html.theme-dark body #bg-light,
html.theme-dark body #border-topss,
html.theme-dark body .faq-section { background: var(--night-bg) !important; }
html.theme-dark body .discover-categories-section *,
html.theme-dark body [style*="--category-bg"] { --category-bg: var(--night-panel); }
html.theme-dark body [style*="linear-gradient"][style*="#fff"],
html.theme-dark body [style*="linear-gradient"][style*="#f5f"],
html.theme-dark body [style*="linear-gradient"][style*="#f8f"],
html.theme-dark body [style*="background:#fff"],
html.theme-dark body [style*="background: #fff"] { background-image: none !important; background-color: transparent !important; }
html.theme-dark .bg-warning, html.theme-dark .bg-warning * { color: #1f2937 !important; }

/* checkboxes and radios stay visible */
html.theme-dark body .form-check-input { background-color: #0f1729 !important; border: 1px solid #5b6b88 !important; }
html.theme-dark body .form-check-input:checked { background-color: #2563eb !important; border-color: #2563eb !important; }

/* muted helper text */
html.theme-dark .text-muted, html.theme-dark .text-secondary, html.theme-dark small, html.theme-dark .small { color: var(--night-muted) !important; }
html.theme-dark h1, html.theme-dark h2, html.theme-dark h3, html.theme-dark h4, html.theme-dark h5, html.theme-dark h6 { color: #f5f7fb !important; }
html.theme-dark a:not(.btn):not(.nws-button):not(.join-btn):not(.become-tutor):not(.desk-cart):not(.theme-toggle) { color: #8ab4ff !important; }
html.theme-dark .nav-menu a, html.theme-dark .mnav-foot a, html.theme-dark .mnav-grid a { color: var(--night-text) !important; }
html.theme-dark .text-dark { color: var(--night-text) !important; }
html.theme-dark .text-body { color: var(--night-text) !important; }

/* ---- 2. real surfaces: panels with their own dark colour ---- */
html.theme-dark body .card,
html.theme-dark body .card-header,
html.theme-dark body .card-footer,
html.theme-dark body .accordion-item,
html.theme-dark body .accordion-button,
html.theme-dark body .list-group-item,
html.theme-dark body .dropdown-menu,
html.theme-dark body .modal-content,
html.theme-dark body .offcanvas,
html.theme-dark body .popover,
html.theme-dark body .nav-dropdown.nav-card,
html.theme-dark body .mnav-drawer,
html.theme-dark body .auth-card,
html.theme-dark body .auth-form-wrap,
html.theme-dark body .table,
html.theme-dark body .table td,
html.theme-dark body .table th,
html.theme-dark body [class*="-card"],
html.theme-dark body [class*="card-"],
html.theme-dark body .contact-area-content,
html.theme-dark body .contact-address-details,
html.theme-dark body #navigation,
html.theme-dark body .header,
html.theme-dark body .page-title,
html.theme-dark body .gray-simple,
html.theme-dark body .bg-white,
html.theme-dark body .bg-light,
html.theme-dark body .section-bg,
html.theme-dark body .blog-sidebar .card {
    background-color: var(--night-panel) !important;
    border-color: var(--night-line) !important;
}
html.theme-dark body .auth-card { background-color: var(--night-panel) !important; }
html.theme-dark body .auth-aside { background: linear-gradient(150deg, #1e3a8a 0%, #2563eb 55%, #7c3aed 100%) !important; }
html.theme-dark body .auth-page { background: linear-gradient(120deg, #3b2464 0%, #1f2a5a 100%) !important; }

/* form controls */
html.theme-dark body .form-control, html.theme-dark body .form-select,
html.theme-dark body input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
html.theme-dark body textarea, html.theme-dark body select {
    background-color: #0f1729 !important;
    color: var(--night-text) !important;
    border-color: #2c3852 !important;
}
html.theme-dark body .form-control::placeholder, html.theme-dark body textarea::placeholder { color: #7f8ba3 !important; }
html.theme-dark body .auth-tabs { background-color: #0f1729 !important; }
html.theme-dark body .auth-tabs a.active { background-color: #22304a !important; color: #fff !important; }
html.theme-dark body .btn-google, html.theme-dark body .btn-facebook { background-color: #1a2437 !important; color: var(--night-text) !important; border-color: #2c3852 !important; }
html.theme-dark body .btn-light, html.theme-dark body .btn-outline-secondary { background-color: #1a2437 !important; color: var(--night-text) !important; border-color: #2c3852 !important; }

/* sticky header: keep it solid so text under it does not show through */
html.theme-dark body .header, html.theme-dark body .header-area { background-color: #101828 !important; }
html.theme-dark body #navigation,
html.theme-dark body #navigation .nav-menu-social,
html.theme-dark body #navigation .nav-menu-social > li { background-color: transparent !important; }
/* header links look like light mode, just light: no blue link colour */
html.theme-dark body #navigation .nav-menu > li > a { color: var(--night-text) !important; }
html.theme-dark body #navigation .nav-menu > li.active > a,
html.theme-dark body #navigation .nav-menu > li > a:hover { color: #fff !important; }
/* "Become a Tutor" / "Sign In" pills keep white text like in light mode */
html.theme-dark body #navigation .become-tutor > a,
html.theme-dark body #navigation .join-btn > a,
html.theme-dark body #navigation .become-tutor > a *,
html.theme-dark body #navigation .join-btn > a * { color: #fff !important; }
html.theme-dark body .course-buybar { background-color: #101828 !important; border-top-color: var(--night-line) !important; }
/* white pill buttons keep dark text */
html.theme-dark body .btn-whites, html.theme-dark body .btn-whites * { color: #0b1220 !important; }

/* keep the footer and images as designed */
html.theme-dark img, html.theme-dark video { opacity: .97; }

/* the sign-in modal and forms on the home page */
html.theme-dark body #myModal .modal-body, html.theme-dark body #myModal .modal-content { background-color: var(--night-panel) !important; }

/* Site pager */
[data-bs-theme="dark"] .site-pager .sp-btn { background: #1c2740 !important; border-color: #2c3a57 !important; color: #e2e8f0 !important; }
[data-bs-theme="dark"] .site-pager a.sp-btn:hover { border-color: #60a5fa !important; color: #93c5fd !important; }
[data-bs-theme="dark"] .site-pager .sp-btn.is-disabled { background: #141c2e !important; color: #64748b !important; }
[data-bs-theme="dark"] .site-pager .sp-page { color: #cbd5e1 !important; }
[data-bs-theme="dark"] .site-pager a.sp-page:hover { background: #1c2740 !important; color: #93c5fd !important; }
[data-bs-theme="dark"] .site-pager .sp-page.is-current { color: #fff !important; }
[data-bs-theme="dark"] .site-pager .sp-status strong { color: #f1f5f9 !important; }
