/* Base Theme Fallback */
:root {
    --bs-primary: #0d6efd;
    --bs-primary-rgb: 13, 110, 253;
}

html, body {
    height: 100%;
    background-color: var(--bs-body-bg, #F4ECE1);
    color: var(--bs-body-color, #2D2424);
}

/* Tenant Dynamic Subtle Palettes */
.bg-primary-subtle {
    background-color: rgba(var(--bs-primary-rgb), 0.08) !important;
}

.border-primary-subtle {
    border-color: rgba(var(--bs-primary-rgb), 0.18) !important;
}

.text-primary-emphasis {
    color: var(--bs-primary) !important;
}

/* Tenant Modal */
.tenant-modal {
    background-color: var(--bs-card-bg, #EFE6D8);
    color: var(--bs-body-color, #2D2424);
}

.btn-white {
    background-color: #ffffff;
    color: var(--bs-body-color, #2D2424);
    border-color: rgba(0, 0, 0, 0.08);
}

[data-bs-theme="dark"] .btn-white {
    background-color: var(--bs-card-bg);
    color: var(--bs-body-color);
    border-color: rgba(255, 255, 255, 0.12);
}

.btn-white:hover,
.btn-white:focus {
    background-color: #fdfdfd;
    color: var(--bs-primary);
    border-color: rgba(var(--bs-primary-rgb), 0.25);
}

[data-bs-theme="dark"] .btn-white:hover,
[data-bs-theme="dark"] .btn-white:focus {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--bs-primary);
}

/* Tenant Dynamic Theme Bindings for Bootstrap 5 */
.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--bs-primary);
    --bs-btn-hover-border-color: var(--bs-primary);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--bs-primary);
    --bs-btn-active-border-color: var(--bs-primary);
    --bs-btn-focus-shadow-rgb: var(--bs-primary-rgb);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--bs-primary);
    --bs-btn-disabled-border-color: var(--bs-primary);
    --bs-btn-disabled-opacity: 0.85;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:focus-visible,
.btn-primary:active,
.btn-primary.active {
    color: #fff;
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    filter: brightness(1.08);
}

.btn-primary:focus,
.btn-primary:focus-visible {
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
}

.btn-primary:disabled,
.btn-primary.disabled,
fieldset:disabled .btn-primary {
    color: #fff !important;
    background-color: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
    opacity: 0.85 !important;
}

.btn-outline-primary {
    --bs-btn-color: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: var(--bs-primary);
    --bs-btn-hover-border-color: var(--bs-primary);
    --bs-btn-active-bg: var(--bs-primary);
    --bs-btn-active-border-color: var(--bs-primary);
    --bs-btn-disabled-color: var(--bs-primary);
    --bs-btn-disabled-border-color: var(--bs-primary);
}

.btn-outline-primary:hover .bg-primary-subtle {
    background-color: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}

.btn-outline-primary:hover .text-secondary {
    color: rgba(255, 255, 255, 0.8) !important;
}

.btn-outline-primary:disabled,
.btn-outline-primary.disabled,
fieldset:disabled .btn-outline-primary {
    color: var(--bs-primary) !important;
    background-color: transparent !important;
    border-color: var(--bs-primary) !important;
    opacity: 0.85 !important;
}

.btn .spinner-border {
    color: inherit;
}


.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.2);
}

.form-check-input:checked {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

/* Unified Input Group Focus & Validation */
.input-group .form-control,
.input-group .input-group-text {
    transition: none;
}

.input-group:focus-within {
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.15);
}

.input-group:focus-within .input-group-text,
.input-group:focus-within .form-control {
    border-color: var(--bs-primary);
}

.input-group:focus-within .input-group-text svg {
    stroke: var(--bs-primary);
}

.input-group > .form-control:focus {
    box-shadow: none;
}

.toggle-pwd {
    cursor: pointer;
}

.toggle-pwd:focus,
.toggle-pwd:active {
    box-shadow: none !important;
}

.input-group:has(.is-invalid),
.input-group.is-invalid {
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-danger-rgb, 220, 53, 69), 0.15) !important;
}

.input-group:has(.is-invalid) .input-group-text,
.input-group:has(.is-invalid) .form-control,
.input-group.is-invalid .input-group-text,
.input-group.is-invalid .form-control {
    border-color: var(--bs-form-invalid-border-color, #dc3545) !important;
}

.input-group:has(.is-invalid) .input-group-text svg,
.input-group.is-invalid .input-group-text svg {
    stroke: var(--bs-form-invalid-border-color, #dc3545);
}

.input-group > .form-control:not(:last-child).is-invalid {
    background-image: none;
}

/* Auth Containers & Utilities (rem-based) */
.auth-container {
    max-width: 42.5rem;
}

.auth-form-container {
    max-width: 26rem;
}

.auth-logo {
    max-width: 11.25rem;
    max-height: 3.75rem;
    object-fit: contain;
}

.back-btn {
    width: 2.75rem;
    height: 2.75rem;
}

.card {
    --bs-card-bg: var(--tenant-card-bg, #EFE6D8);
    background-color: var(--bs-card-bg);
}

.card-hover {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-hover:hover {
    transform: translateY(-0.25rem);
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.08) !important;
}

.ratio-4x5 {
    --bs-aspect-ratio: 125%;
}

/* Wizard & OTP Specific Dimensions */
.wizard-form-container {
    max-width: 28rem;
}

.wizard-progress-bar {
    height: 0.3rem;
    border-radius: 0.15rem;
    background-color: rgba(var(--bs-primary-rgb), 0.18);
    transition: background-color 0.25s ease-in-out;
}

.wizard-progress-bar.active {
    background-color: var(--bs-primary);
}

.otp-box {
    width: 3.25rem;
    height: 3.75rem;
}

/* RTL Icon Flip */
[dir="rtl"] .back-btn svg,
[dir="rtl"] svg.chevron-arrow {
    transform: scaleX(-1);
}

/* Sidebar */
.app-sidebar {
    width: 6.25rem;
    min-height: 100vh;
    flex-shrink: 0;
}

.sidebar-logo {
    max-width: 4.5rem;
    max-height: 2.5rem;
    object-fit: contain;
}

.status-dot {
    width: 0.45rem;
    height: 0.45rem;
}

.sidebar-nav-item {
    width: 4.5rem;
    height: 4.5rem;
    font-size: 0.75rem;
}

.sidebar-nav-item.active,
.sidebar-nav-link.active {
    background-color: #f7eeee;
    color: var(--bs-primary) !important;
}

.sidebar-nav-item.active svg,
.sidebar-nav-link.active svg {
    stroke: var(--bs-primary);
}

/* Books Grid & Cards */
.book-card {
    width: 13.5rem;
    max-width: 100%;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    background-color: #ffffff;
}

.book-title {
    color: #2D2424;
    transition: color 0.2s ease;
}

.book-card:hover .book-title {
    color: var(--bs-primary, #630004);
}

.book-card:hover {
    transform: translateY(-0.35rem);
    box-shadow: 0 0.75rem 1.75rem rgba(0, 0, 0, 0.08) !important;
}

.book-card .book-cover-img {
    transition: transform 0.25s ease;
}

.book-card:hover .book-cover-img {
    transform: scale(1.02);
}

.book-cover-placeholder {
    background: linear-gradient(150deg, #1b0002 0%, var(--bs-primary, #630004) 60%, #8c1a20 100%);
}

/* PJAX Transition */
.app-content-fade {
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
}

/* Dark Mode Theme Tokens & Fallbacks (Option A: Royal Crimson & Obsidian) */
[data-bs-theme="dark"] body {
    background-color: var(--bs-body-bg, #0E0E12);
    color: var(--bs-body-color, #F3F4F6);
}

[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .card.bg-white,
[data-bs-theme="dark"] .book-card {
    --bs-card-bg: var(--tenant-card-bg, #18181F);
    background-color: var(--bs-card-bg) !important;
    color: var(--bs-body-color, #F3F4F6) !important;
    border: 0.0625rem solid rgba(255, 255, 255, 0.08) !important;
}

[data-bs-theme="dark"] .tenant-modal,
[data-bs-theme="dark"] .modal-content {
    background-color: var(--bs-card-bg, #18181F) !important;
    color: var(--bs-body-color, #F3F4F6) !important;
    border: 0.0625rem solid rgba(255, 255, 255, 0.08) !important;
}

[data-bs-theme="dark"] header.bg-white,
[data-bs-theme="dark"] header,
[data-bs-theme="dark"] .app-sidebar,
[data-bs-theme="dark"] #mainSidebar,
[data-bs-theme="dark"] .offcanvas {
    background-color: var(--bs-card-bg, #18181F) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
}

[data-bs-theme="dark"] .app-sidebar .sidebar-logo,
[data-bs-theme="dark"] header .sidebar-logo,
[data-bs-theme="dark"] .offcanvas-header .sidebar-logo {
    background-color: #ffffff;
    padding: 0.35rem 0.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.375rem rgba(0, 0, 0, 0.25);
}

[data-bs-theme="dark"] .sidebar-nav-item.active,
[data-bs-theme="dark"] .sidebar-nav-link.active {
    background-color: rgba(var(--bs-primary-rgb), 0.18) !important;
    color: var(--bs-primary) !important;
}

[data-bs-theme="dark"] .btn-light {
    background-color: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: var(--bs-body-color, #F3F4F6) !important;
}

[data-bs-theme="dark"] .btn-light:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .btn-white,
[data-bs-theme="dark"] .btn-white.bg-white {
    background-color: rgba(255, 255, 255, 0.06) !important;
    color: var(--bs-body-color, #F3F4F6) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}

[data-bs-theme="dark"] .btn-white:hover,
[data-bs-theme="dark"] .btn-white:focus,
[data-bs-theme="dark"] .btn-white.bg-white:hover,
[data-bs-theme="dark"] .btn-white.bg-white:focus {
    background-color: rgba(255, 255, 255, 0.12) !important;
    color: var(--bs-primary) !important;
}

[data-bs-theme="dark"] .bg-primary-subtle {
    background-color: rgba(var(--bs-primary-rgb), 0.16) !important;
}

[data-bs-theme="dark"] .border-primary-subtle {
    border-color: rgba(var(--bs-primary-rgb), 0.3) !important;
}

[data-bs-theme="dark"] .badge.text-primary,
[data-bs-theme="dark"] .text-primary-emphasis {
    color: #F87171 !important;
}

[data-bs-theme="dark"] .text-dark {
    color: var(--bs-body-color, #F3F4F6) !important;
}

[data-bs-theme="dark"] .book-title {
    color: #F9FAFB !important;
}

[data-bs-theme="dark"] .book-card:hover .book-title {
    color: var(--bs-link-color, #E04356) !important;
}

[data-bs-theme="dark"] .bg-white .book-title,
[data-bs-theme="dark"] .card.bg-white .book-title {
    color: #1F2937 !important;
}

[data-bs-theme="dark"] .text-secondary {
    color: #9CA3AF !important;
}

[data-bs-theme="dark"] .border-bottom,
[data-bs-theme="dark"] .border-top,
[data-bs-theme="dark"] .border-start,
[data-bs-theme="dark"] .border-end,
[data-bs-theme="dark"] .border {
    border-color: rgba(255, 255, 255, 0.08) !important;
}

.list-group-item-action:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.04) !important;
}

[data-bs-theme="dark"] .list-group-item-action:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

.list-group-item-action:focus,
.list-group-item-action:active {
    background-color: transparent !important;
    outline: none !important;
    box-shadow: none !important;
}

.list-group-item-action:focus:hover,
.list-group-item-action:active:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.04) !important;
}

[data-bs-theme="dark"] .list-group-item-action:focus:hover,
[data-bs-theme="dark"] .list-group-item-action:active:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .input-group-text,
[data-bs-theme="dark"] .form-control.bg-white,
[data-bs-theme="dark"] .input-group-text.bg-white {
    background-color: rgba(255, 255, 255, 0.06) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: var(--bs-body-color, #F3F4F6) !important;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-control.bg-white:focus {
    background-color: rgba(255, 255, 255, 0.09) !important;
    border-color: var(--bs-primary) !important;
    color: #ffffff !important;
}

.hero-student-wrapper {
    width: 100%;
    max-width: 32rem;
}

.hero-student-img {
    height: 32rem;
    max-height: 70vh;
    width: 100%;
    object-fit: cover;
    object-position: top center;
}

@media (max-width: 575.98px) {
    .hero-student-img {
        height: 20rem;
        max-height: 50vh;
    }
}

