/* Theme (light / dark) — hand-written parts.
   The bulk of the dark palette is generated into dark-theme.css
   (see tools/build-dark-theme.py). */

/* ── Header sun / moon toggle ───────────────────────────────── */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #414141;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease;
}

/* ≤575px custom.css pins the bell (position: fixed; left: 80px) — keep it clear of the toggle */
@media (max-width: 575px) {
    .user-panel-header .notification-dropdown { left: 126px; }
}

.theme-toggle-btn { flex-shrink: 0; }

.theme-toggle-btn:hover {
    background: rgba(42, 95, 69, 0.1);
    color: #2a5f45;
}

.theme-toggle-btn:focus-visible {
    outline: 2px solid #2a5f45;
    outline-offset: 2px;
}

.theme-toggle-btn .theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle-btn .theme-icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle-btn .theme-icon-moon { display: none; }

/* ── Language dropdown (headers) ────────────────────────────── */
.lang-dropdown { position: relative; }

.lang-dropdown .lang-current {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #414141;
    cursor: pointer;
    font: inherit;
    line-height: 1.2;
    transition: background-color .2s ease;
}

.lang-dropdown .lang-current:hover { background: rgba(42, 95, 69, 0.1); }
.lang-dropdown .lang-current:focus-visible { outline: 2px solid #2a5f45; outline-offset: 2px; }
.lang-dropdown .language-text { white-space: nowrap; }
.lang-dropdown .lang-chevron { transition: transform .2s ease; }
.lang-dropdown.is-open .lang-chevron { transform: rotate(180deg); }

.lang-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-start: 0;
    z-index: 1100;
    min-width: 130px;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.lang-dropdown.is-open .lang-menu { display: block; }

.lang-menu a {
    display: block;
    padding: 8px 12px;
    border-radius: 6px;
    color: #414141;
    text-decoration: none;
    white-space: nowrap;
}

.lang-menu a:hover { background: rgba(42, 95, 69, 0.08); }
.lang-menu a.active { background: #2a5f45; color: #fff; }

.language-option-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(42, 95, 69, 0.1);
    color: #2a5f45;
    font-size: 26px;
    font-weight: 600;
}

/* ── Profile page: theme selector ───────────────────────────── */
.theme-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    max-width: 530px;
}

.theme-option {
    position: relative;
    flex: 1 1 100px;
    margin: 0;
    cursor: pointer;
}

.theme-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-option-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 2px solid #e8e8e8;
    border-radius: 12px;
    background: #fff;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.theme-option:hover .theme-option-card { border-color: #9cc3af; }

.theme-option input:checked + .theme-option-card {
    border-color: #2a5f45;
    box-shadow: 0 0 0 3px rgba(42, 95, 69, 0.18);
}

.theme-option input:focus-visible + .theme-option-card {
    outline: 2px solid #2a5f45;
    outline-offset: 2px;
}

.theme-option-preview {
    display: block;
    width: 100%;
    height: 54px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
}

.theme-option-preview-light  { background: linear-gradient(#ffffff 0 30%, #faf9f3 30% 100%); }
.theme-option-preview-dark   { background: linear-gradient(#16201b 0 30%, #0f1713 30% 100%); }
.theme-option-preview-system { background: linear-gradient(115deg, #ffffff 0 50%, #16201b 50% 100%); }

.theme-option-label {
    font-size: 15px;
    color: #414141;
}

@media (max-width: 575px) {
    .theme-options { flex-wrap: nowrap; gap: 8px; }
    .theme-option { flex: 1 1 0; min-width: 0; }
    .theme-option-card { padding: 8px; }
}


/* ── Dark: things the generator can't see (3rd-party widgets, images…) ── */
@media screen {
    html[data-theme="dark"] body {
        background-color: #0f1713;
        color: #d4ddd9;
    }

    /* Bootstrap utilities whose colours come from -rgb variables */
    html[data-theme="dark"] .bg-white,
    html[data-theme="dark"] .bg-body,
    html[data-theme="dark"] .bg-light { background-color: #16201b !important; }
    html[data-theme="dark"] .text-dark,
    html[data-theme="dark"] .text-black,
    html[data-theme="dark"] .text-body { color: #d4ddd9 !important; }
    html[data-theme="dark"] .border-light,
    html[data-theme="dark"] .border-white { border-color: #2e4238 !important; }

    /* light-only decorative pattern behind the login / reset cards */
    html[data-theme="dark"] .login-form-container { background-image: none !important; }

    /* footer logo: square white PNG of a round emblem — clip to the circle */
    html[data-theme="dark"] img[src$="/footer-logo.png"] {
        border-radius: 50%;
        background: #fff;
    }

    /* footer contact icons (mid-grey strokes) */
    html[data-theme="dark"] .pre-footer-section img[src$="/phone-call.svg"],
    html[data-theme="dark"] .pre-footer-section img[src$="/mail.svg"],
    html[data-theme="dark"] .pre-footer-section img[src$="/map-pin.svg"] {
        filter: brightness(1.7);
    }

    /* footer social icons (green discs) — lift slightly off the dark surface */
    html[data-theme="dark"] .footer-social-icons img {
        filter: brightness(1.25) saturate(1.1);
    }

    /* light placeholders / avatars shouldn't glare on a dark surface */
    html[data-theme="dark"] img[src$="/upload-image.png"],
    html[data-theme="dark"] img[src$="/user-image-placeholder.jpg"] {
        filter: brightness(.82);
    }

    /* user-uploaded signatures are dark ink — keep them on white paper */
    html[data-theme="dark"] .mf-signature-img,
    html[data-theme="dark"] img[src*="signature-images/"] {
        background: #fff;
        border-radius: 6px;
    }

    /* the green logo is too dim on a dark surface */
    html[data-theme="dark"] .logo img,
    html[data-theme="dark"] .user-panel-header-right-logo img {
        filter: brightness(1.9) saturate(1.1);
    }

    html[data-theme="dark"] .theme-toggle-btn { color: #d4ddd9; }
    html[data-theme="dark"] .theme-toggle-btn:hover {
        background: rgba(111, 201, 154, 0.14);
        color: #6fc99a;
    }

    html[data-theme="dark"] .theme-option-card {
        background: #16201b;
        border-color: #2e4238;
    }
    html[data-theme="dark"] .theme-option:hover .theme-option-card { border-color: #4f7a64; }
    html[data-theme="dark"] .theme-option input:checked + .theme-option-card {
        border-color: #6fc99a;
        box-shadow: 0 0 0 3px rgba(111, 201, 154, 0.2);
    }
    html[data-theme="dark"] .theme-option-label { color: #d4ddd9; }
    html[data-theme="dark"] .theme-option-preview { border-color: rgba(255, 255, 255, 0.16); }

    /* CKEditor 5 (answer editors) */
    html[data-theme="dark"] .ck {
        --ck-color-base-foreground: #1d2a23;
        --ck-color-base-background: #141d18;
        --ck-color-base-border: #2e4238;
        --ck-color-base-text: #d4ddd9;
        --ck-color-base-active: #6fc99a;
        --ck-color-base-active-focus: #8bd6b0;
        --ck-color-focus-border: #6fc99a;
        --ck-color-text: #d4ddd9;
        --ck-color-shadow-drop: rgba(0, 0, 0, 0.4);
        --ck-color-shadow-inner: rgba(0, 0, 0, 0.3);
        --ck-color-button-default-hover-background: #26362d;
        --ck-color-button-default-active-background: #2c3f34;
        --ck-color-button-on-background: #26362d;
        --ck-color-button-on-hover-background: #2c3f34;
        --ck-color-button-on-active-background: #31463a;
        --ck-color-button-on-color: #6fc99a;
        --ck-color-panel-background: #1d2a23;
        --ck-color-panel-border: #2e4238;
        --ck-color-toolbar-background: #1d2a23;
        --ck-color-toolbar-border: #2e4238;
        --ck-color-dropdown-panel-background: #1d2a23;
        --ck-color-dropdown-panel-border: #2e4238;
        --ck-color-list-background: #1d2a23;
        --ck-color-list-button-hover-background: #26362d;
        --ck-color-list-button-on-background: #2a5f45;
        --ck-color-input-background: #141d18;
        --ck-color-input-border: #2e4238;
        --ck-color-input-text: #d4ddd9;
        --ck-color-tooltip-background: #d4ddd9;
        --ck-color-tooltip-text: #141d18;
    }
    html[data-theme="dark"] .ck.ck-editor__editable:not(.ck-editor__nested-editable),
    html[data-theme="dark"] .ck.ck-content {
        background: #141d18;
        color: #d4ddd9;
    }

    /* SweetAlert2 */
    html[data-theme="dark"] .swal2-popup {
        background: #1d2a23;
        color: #d4ddd9;
    }
    html[data-theme="dark"] .swal2-title,
    html[data-theme="dark"] .swal2-html-container { color: #d4ddd9; }
    html[data-theme="dark"] .swal2-input,
    html[data-theme="dark"] .swal2-textarea,
    html[data-theme="dark"] .swal2-select {
        background: #141d18;
        color: #d4ddd9;
        border-color: #2e4238;
    }

    /* Select2 (public forms) */
    html[data-theme="dark"] .select2-container--default .select2-selection--single,
    html[data-theme="dark"] .select2-container--default .select2-selection--multiple,
    html[data-theme="dark"] .select2-dropdown {
        background-color: #141d18;
        border-color: #2e4238;
        color: #d4ddd9;
    }
    html[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered,
    html[data-theme="dark"] .select2-results__option { color: #d4ddd9; }
    html[data-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected],
    html[data-theme="dark"] .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
        background-color: #2a5f45;
        color: #fff;
    }
    html[data-theme="dark"] .select2-container--default .select2-results__option[aria-selected=true],
    html[data-theme="dark"] .select2-container--default .select2-results__option--selected {
        background-color: #26362d;
    }
    html[data-theme="dark"] .select2-search--dropdown .select2-search__field {
        background: #141d18;
        color: #d4ddd9;
        border-color: #2e4238;
    }

    /* On/off switch (profile → email notifications) */
    html[data-theme="dark"] .switch .slider { background-color: #3a4f44; }
    html[data-theme="dark"] .switch .slider:before { background-color: #d4ddd9; }
    html[data-theme="dark"] .switch input:checked + .slider { background-color: #2e8b5e; }
    html[data-theme="dark"] .switch input:checked + .slider:before { background-color: #fff; }
    html[data-theme="dark"] .switch input:focus-visible + .slider {
        box-shadow: 0 0 0 3px rgba(111, 201, 154, 0.35);
    }

    /* calendar button next to the datepicker inputs blends with the input */
    html[data-theme="dark"] .mf-date-wrap .input-group-text.mf-date-icon-btn {
        background-color: #111a16;
        border: none;
    }
    html[data-theme="dark"] .mf-date-wrap .mf-input.mf-date-input { background-color: #111a16; }

    /* bootstrap-datepicker (public forms + panel add/edit fatwa forms) */
    html[data-theme="dark"] .datepicker.dropdown-menu {
        background-color: #16201b;
        border: 1px solid #2e4238;
        color: #d4ddd9;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    }
    html[data-theme="dark"] .datepicker-dropdown:before { border-bottom-color: #2e4238; }
    html[data-theme="dark"] .datepicker-dropdown:after { border-bottom-color: #16201b; }
    html[data-theme="dark"] .datepicker table tr th,
    html[data-theme="dark"] .datepicker table tr td { color: #d4ddd9; }
    html[data-theme="dark"] .datepicker table tr td.old,
    html[data-theme="dark"] .datepicker table tr td.new,
    html[data-theme="dark"] .datepicker table tr td span.old,
    html[data-theme="dark"] .datepicker table tr td span.new { color: #5f7368; }
    html[data-theme="dark"] .datepicker table tr td.disabled,
    html[data-theme="dark"] .datepicker table tr td.disabled:hover,
    html[data-theme="dark"] .datepicker table tr td span.disabled,
    html[data-theme="dark"] .datepicker table tr td span.disabled:hover { color: #44564c; background: none; }
    html[data-theme="dark"] .datepicker table tr td.day:hover,
    html[data-theme="dark"] .datepicker table tr td.focused,
    html[data-theme="dark"] .datepicker table tr td span:hover,
    html[data-theme="dark"] .datepicker table tr td span.focused,
    html[data-theme="dark"] .datepicker .datepicker-switch:hover,
    html[data-theme="dark"] .datepicker .prev:hover,
    html[data-theme="dark"] .datepicker .next:hover,
    html[data-theme="dark"] .datepicker tfoot tr th:hover {
        background: #26362d;
        color: #fff;
    }
    html[data-theme="dark"] .datepicker table tr td.today,
    html[data-theme="dark"] .datepicker table tr td.today:hover {
        background: #4a3d1c;
        color: #f3d98a;
    }
    html[data-theme="dark"] .datepicker table tr td.active,
    html[data-theme="dark"] .datepicker table tr td.active:hover,
    html[data-theme="dark"] .datepicker table tr td.active.active,
    html[data-theme="dark"] .datepicker table tr td.selected,
    html[data-theme="dark"] .datepicker table tr td.selected:hover,
    html[data-theme="dark"] .datepicker table tr td span.active,
    html[data-theme="dark"] .datepicker table tr td span.active:hover {
        background: #2a5f45;
        color: #fff;
        text-shadow: none;
    }

    html[data-theme="dark"] .lang-dropdown .lang-current { color: #d4ddd9; }
    html[data-theme="dark"] .lang-dropdown .lang-current:hover { background: rgba(111, 201, 154, 0.14); }
    html[data-theme="dark"] .lang-menu { background: #1d2a23; border-color: #2e4238; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
    html[data-theme="dark"] .lang-menu a { color: #d4ddd9; }
    html[data-theme="dark"] .lang-menu a:hover { background: #26362d; }
    html[data-theme="dark"] .lang-menu a.active { background: #2a5f45; color: #fff; }
    html[data-theme="dark"] .language-option-badge { background: rgba(111, 201, 154, 0.14); color: #6fc99a; }

    /* Scrollbars (WebKit) */
    html[data-theme="dark"] ::-webkit-scrollbar-track { background: #141d18; }
    html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #35493f; border-radius: 6px; }
    html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #4a6557; }
}

/* ===== select2 in Urdu (RTL): arrow on the left, × just right of it, text right-aligned clear of both ===== */
html[dir="rtl"] .select2-container--default .select2-selection--single,
html[dir="rtl"] .select2-container--default .select2-selection--multiple { position: relative; }
html[dir="rtl"] .select2-container--default .select2-selection--single .select2-selection__rendered,
html[dir="rtl"] .select2-container--default .select2-selection--multiple .select2-selection__rendered {
    position: static; direction: rtl; text-align: right;
}
html[dir="rtl"] .select2-container--default .select2-selection--single .select2-selection__rendered { padding-left: 62px; padding-right: 12px; }
html[dir="rtl"] .select2-container--default .select2-selection--multiple .select2-selection__rendered { padding-left: 30px; padding-right: 8px; }
html[dir="rtl"] .select2-container--default .select2-selection--single .select2-selection__placeholder,
html[dir="rtl"] .select2-container--default .select2-selection--multiple .select2-search__field { text-align: right; direction: rtl; }
html[dir="rtl"] .select2-container--default .select2-selection__clear {
    position: absolute; top: 50%; transform: translateY(-50%);
    float: none; margin: 0; padding: 0 4px; height: auto;
    line-height: 1; font-size: 18px; font-weight: 400; color: #888;
    background: transparent; border: 0; cursor: pointer;
    right: auto; left: 38px;
}
html[dir="rtl"] .select2-container--default .select2-selection--multiple .select2-selection__clear { left: 8px; }
html[dir="rtl"] .select2-container--default .select2-selection__clear:hover { color: #2A5F45; }
html[dir="rtl"] .select2-container .select2-selection--single { flex-direction: row !important; }
html[dir="rtl"] .select2-container--default .select2-selection--single .select2-selection__rendered { flex: 1 1 auto; }
