/* Dark mode (Oct 2026), following the device setting like the Android app. Loaded after
   the page styles so these overrides win; the app bar stays brand green in both modes. */

:root {
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --ac-background: #0F1412;
        --ac-text: #F3F5F4;
        --ac-text-secondary: #8B9690;
        --ac-card-surface: #171D1A;
        --ac-card-stroke: rgba(255, 255, 255, 0.15);
        --ac-card-shadow: none;
        --ac-thumbnail-placeholder: #20281F;
        --ac-link: #34D399;
        --ac-divider: #1E2521;
        --ac-input-background: #171D1A;
        --ac-course-price: #F3F5F4;
        --ac-course-original-price: #6B7570;
        --ac-slider-dot-active: #34D399;
        --ac-slider-dot-inactive: #3A443F;
        /* Older page styles read these. */
        --background-color: #0F1412;
        --text-primary: #F3F5F4;
    }

    html,
    body {
        background-color: var(--ac-background) !important;
        color: var(--ac-text);
    }

    a {
        color: var(--ac-link);
    }

    h1, h2, h3, h4, h5, h6,
    .h1, .h2, .h3, .h4, .h5, .h6,
    .text-dark,
    .text-body {
        color: var(--ac-text) !important;
    }

    .text-muted,
    .text-secondary {
        color: var(--ac-text-secondary) !important;
    }

    hr,
    .border,
    .border-top,
    .border-bottom,
    .border-left,
    .border-right {
        border-color: var(--ac-divider) !important;
    }

    .card,
    .bg-white,
    .bg-light,
    .modal-content,
    .popover,
    .dropdown-menu,
    .list-group-item,
    .course-details-info-card {
        background-color: var(--ac-card-surface) !important;
        border-color: var(--ac-card-stroke) !important;
        color: var(--ac-text);
    }

    .modal-header,
    .modal-footer,
    .popover-header,
    .info-row,
    .content-card {
        border-color: var(--ac-divider) !important;
    }

    .popover-header {
        background-color: var(--ac-card-surface) !important;
        color: var(--ac-text);
    }

    /* Plain Bootstrap buttons default to near-black text. */
    .btn:not([class*="btn-"]),
    .btn-link,
    .btn-outline-dark,
    .btn-outline-secondary {
        color: var(--ac-text) !important;
    }

    .close {
        color: var(--ac-text);
        text-shadow: none;
    }

    .table {
        color: var(--ac-text);
    }

    .table td,
    .table th {
        border-color: var(--ac-divider);
    }

    .form-control,
    input:not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]):not([type=range]):not([type=file]),
    textarea,
    select {
        background-color: var(--ac-input-background) !important;
        border-color: var(--ac-card-stroke) !important;
        color: var(--ac-text) !important;
    }

    .form-control::placeholder {
        color: var(--ac-text-secondary);
    }

    input:-webkit-autofill,
    textarea:-webkit-autofill,
    select:-webkit-autofill {
        -webkit-box-shadow: 0 0 0 1000px var(--ac-input-background) inset !important;
        -webkit-text-fill-color: var(--ac-text) !important;
    }

    /* Side menu */
    .sidebar {
        background: var(--ac-card-surface) !important;
    }

    .sidebar-item {
        border-color: var(--ac-divider) !important;
    }

    .sidebar-link {
        color: var(--ac-text) !important;
    }

    .sidebar-link:hover {
        background: var(--ac-divider) !important;
        color: var(--ac-link) !important;
    }

    /* Login */
    .floating-label {
        background-color: var(--ac-input-background) !important;
        color: var(--ac-text-secondary) !important;
    }

    /* Course details */
    .course-details-description p,
    .course-info-card h3,
    .other-courses-section h3,
    .course-title a {
        color: var(--ac-text) !important;
    }

    .info-label {
        color: var(--ac-text-secondary) !important;
    }

    .course-price,
    .course-price * {
        color: #6EA0FF;
    }

    .course-PriceWithDiscount,
    .course-PriceWithDiscount * {
        color: #E64E4E;
    }

    .footer {
        background-color: #1E2521 !important;
    }
}
