/* Registration and payment use a separate Bootstrap shell. Keep every rule
   dark-only so its existing light palette and layout remain unchanged.
   Entry points: layouts/app and financial_programs/payment/head. */
@media screen {
    html[data-bs-theme="dark"] {
        color-scheme: dark;
        --registration-canvas: #13151b;
        --registration-surface: #1e2129;
        --registration-raised: #2b303b;
        --registration-ink: #e8eaf0;
        --registration-muted: #b5bdce;
        --registration-line: #697487;
        --registration-accent: #80d6e5;
        --registration-danger: #ffc2cf;
        --registration-success: #a1efc7;
    }

    [data-bs-theme="dark"] body,
    [data-bs-theme="dark"] #containerag {
        background-color: var(--registration-canvas);
        color: var(--registration-ink);
    }

    [data-bs-theme="dark"] :is(.card, .card-body, .bg-white, .bg-gray-100) {
        background-color: var(--registration-surface);
        color: var(--registration-ink);
        border-color: var(--registration-line);
    }

    /* Bootstrap marks bg-white important. The 403 view uses that utility inside
       layouts/app, so its dark text palette must share a dark surface as well.
       Regression coverage: tests/browser/portal-error-dark.mjs. */
    [data-bs-theme="dark"] .bg-white {
        background-color: var(--registration-surface) !important;
    }

    [data-bs-theme="dark"] .card-body { background-image: none; }
    [data-bs-theme="dark"] :is(.page-title, .card-body li, .text-gray-800) { color: var(--registration-ink); }
    [data-bs-theme="dark"] :is(h3, .icon_button, .text-primary) { color: var(--registration-accent) !important; }
    [data-bs-theme="dark"] :is(.text-muted, .text-gray-600) { color: var(--registration-muted) !important; }
    [data-bs-theme="dark"] :is(.card-body a:not(.btn), a.departmentFile) { color: var(--registration-accent) !important; }
    [data-bs-theme="dark"] :is(.icon_button, .totalFess) { border-color: var(--registration-line); }
    [data-bs-theme="dark"] :is(.totalFeesValue, .text-success) { color: var(--registration-success) !important; }

    [data-bs-theme="dark"] :is(.form-control, .form-select, .input-group > .form-control, .input-group > .form-select) {
        background-color: var(--registration-surface);
        color: var(--registration-ink);
        border-color: var(--registration-line);
    }

    [data-bs-theme="dark"] .form-select {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23e8eaf0' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    }

    [data-bs-theme="dark"] .form-control::placeholder { color: var(--registration-muted); }
    [data-bs-theme="dark"] .input-group-text { background-color: #234651; border-color: var(--registration-line); color: var(--registration-ink); }
    [data-bs-theme="dark"] :is(.form-control, .form-select):is(:disabled, [readonly]) { background-color: var(--registration-raised); color: var(--registration-muted); }
    [data-bs-theme="dark"] .form-check-input { background-color: var(--registration-surface); border-color: var(--registration-line); }
    [data-bs-theme="dark"] .form-check-input:checked { background-color: #0d6377; border-color: var(--registration-accent); }
    [data-bs-theme="dark"] :is(.form-control, .form-select, .form-check-input):focus { border-color: var(--registration-accent); }
    [data-bs-theme="dark"] :is(input, select, textarea, button, a, .select2-selection):focus-visible { outline: 2px solid var(--registration-accent); outline-offset: 2px; }
    [data-bs-theme="dark"] input:autofill { box-shadow: inset 0 0 0 1000px var(--registration-surface); -webkit-text-fill-color: var(--registration-ink); caret-color: var(--registration-ink); }
    [data-bs-theme="dark"] :is(.form-control, .form-select).is-invalid,
    [data-bs-theme="dark"] .was-validated :is(.form-control, .form-select):invalid { border-color: var(--registration-danger) !important; }
    [data-bs-theme="dark"] :is(label.error, .invalid-feedback, .text-danger, .text-red-600) { color: var(--registration-danger) !important; }

    [data-bs-theme="dark"] .btn:is(.btn-primary, .btn-info, .btn-success) {
        background-color: var(--registration-accent);
        border-color: var(--registration-accent);
        color: #07303e;
    }
    [data-bs-theme="dark"] .btn:is(.btn-primary, .btn-info, .btn-success):is(:hover, :active, :focus) { background-color: #a4e4ed; border-color: #a4e4ed; color: #07303e; }
    [data-bs-theme="dark"] .btn:disabled { background-color: var(--registration-raised); color: var(--registration-muted); border-color: var(--registration-line); }
    [data-bs-theme="dark"] .alert-success { background-color: #173e31; border-color: #3e8665; color: var(--registration-success); }
    [data-bs-theme="dark"] :is(.alert-danger, .swal2-validation-message) { background-color: #4d2734; color: var(--registration-danger); }
    [data-bs-theme="dark"] .alert-light-primary { background-color: #234651; color: var(--registration-ink); }

    /* Select2 and the phone picker append popovers to body, outside the card. */
    [data-bs-theme="dark"] :is(.select2-dropdown, .select2-container--default .select2-selection--single, .select2-container--default .select2-selection--multiple, .select2-search__field, .iti__country-list) {
        background-color: var(--registration-surface);
        color: var(--registration-ink);
        border-color: var(--registration-line);
    }
    [data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--registration-ink); }
    [data-bs-theme="dark"] .select2-container--default :is(.select2-selection__placeholder, .select2-results__option[aria-disabled="true"]) { color: var(--registration-muted); }
    [data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__arrow b { border-top-color: var(--registration-muted); }
    [data-bs-theme="dark"] .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b { border-bottom-color: var(--registration-muted); }
    [data-bs-theme="dark"] .select2-container--default.select2-container--disabled .select2-selection--single { background-color: var(--registration-raised); }
    [data-bs-theme="dark"] .select2-container--default .select2-results__option[aria-selected="true"] { background-color: var(--registration-raised); }
    [data-bs-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected] { background-color: #234651; color: var(--registration-ink); }
    [data-bs-theme="dark"] .iti__dial-code { color: var(--registration-muted); }
    [data-bs-theme="dark"] :is(.iti__selected-flag, .iti__country.iti__highlight) { background-color: var(--registration-raised); }

    [data-bs-theme="dark"] :is(.filepond--root.filepond.filepond--hopper, .filepond--drop-label, .filepond--panel-root) { background-color: var(--registration-surface); border-color: var(--registration-line); }
    [data-bs-theme="dark"] .filepond--drop-label.filepond--drop-label label { color: var(--registration-muted); }
    [data-bs-theme="dark"] .filepond--item-panel { background-color: #234651; }
    [data-bs-theme="dark"] .filepond--file { color: var(--registration-ink); }
    [data-bs-theme="dark"] [data-filepond-item-state*="error"] .filepond--item-panel { background-color: #4d2734; }
    [data-bs-theme="dark"] [data-filepond-item-state="processing-complete"] .filepond--item-panel { background-color: #173e31; }

    /* Registration feedback is created by SweetAlert after page load. */
    [data-bs-theme="dark"] .swal2-popup { background: var(--registration-surface); color: var(--registration-ink); }
    [data-bs-theme="dark"] :is(.swal2-title, .swal2-html-container, .swal2-footer) { color: var(--registration-ink); }
    [data-bs-theme="dark"] .swal2-styled.swal2-confirm { background-color: var(--registration-accent); color: #07303e; }
    [data-bs-theme="dark"] .swal2-styled.swal2-cancel { background-color: var(--registration-raised); color: var(--registration-ink); }
    [data-bs-theme="dark"] .swal2-close { color: var(--registration-muted); }
}
