/* ============================================
   KJR School Admin — Custom overrides for Bootstrap 5.3.8
   Minimal & Premium CSS on top of Bootstrap
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
    --sidebar-w: 260px;
    --primary-h: 225;
    --primary-s: 70%;
    --primary-l: 40%;
    --bs-body-font-family: 'Sarabun', sans-serif;
    --bs-body-font-size: 1rem;
    --bs-body-color: #000000; /* Pure black in light mode for max readability */
    --bs-body-bg: #f1f5f9;    /* slate-100 for better card contrast and less glare */
    --bs-secondary-color: #475569; /* slate-600 for text-secondary */
    
    /* Global border overrides for clean definition in light theme */
    --bs-border-color: #cbd5e1; /* slate-300 */
    --bs-border-color-translucent: rgba(148, 163, 184, 0.25); /* slate-400 at 25% */

    /* Premium accents */
    --gold-accent: #eab308;
    --indigo-primary: #4f46e5;
    --indigo-hover: #4338ca;
}

body, input, select, textarea, button, table, .card, .sidebar, .modal, .toast {
    font-family: 'Sarabun', sans-serif !important;
}

body {
    font-weight: 400; /* Ensure base font weight is clean and robust */
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ───── Sidebar (desktop fixed / mobile offcanvas) ───── */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #0b0f19 0%, #1e1b4b 100%);
    color: #94a3b8;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow-y: auto;
    transition: transform .3s cubic-bezier(0.16, 1, 0.3, 1);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand {
    padding: 1.75rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.1);
}

.sidebar-brand h6 {
    color: #f8fafc;
    font-weight: 700;
    font-size: 1.05rem;
    margin: 0 0 .25rem;
    letter-spacing: 0.5px;
}

.sidebar-brand small {
    font-size: .75rem;
    color: var(--gold-accent);
    opacity: 0.9;
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem .75rem;
}

.sidebar-nav .nav-section {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #475569;
    padding: 1.25rem .75rem .5rem;
    font-weight: 700;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem .9rem;
    color: #94a3b8;
    border-radius: .5rem;
    font-size: .9rem;
    font-weight: 500;
    transition: all .25s ease;
    margin-bottom: 2px;
    position: relative;
}

.sidebar-nav .nav-link i {
    font-size: 1.15rem;
    width: 1.25rem;
    text-align: center;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #f8fafc;
    padding-left: 1.1rem;
}

.sidebar-nav .nav-link.active {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

.sidebar-nav .nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 15%;
    bottom: 15%;
    width: 3.5px;
    background: var(--gold-accent);
    border-radius: 0 4px 4px 0;
    box-shadow: 0 0 8px var(--gold-accent);
}

.sidebar-footer {
    padding: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.1);
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .85rem;
}

.sidebar-footer .avatar {
    width: 38px; height: 38px;
    border-radius: .6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.avatar-admin { background: linear-gradient(135deg, #4f46e5, #3b82f6); }
.avatar-teacher { background: linear-gradient(135deg, #10b981, #059669); }
.avatar-director { background: linear-gradient(135deg, #f59e0b, #d97706); }

.sidebar-footer .user-name {
    font-size: .85rem;
    font-weight: 600;
    color: #e2e8f0;
    line-height: 1.3;
}

.sidebar-footer .user-role {
    font-size: .72rem;
    color: #64748b;
}

/* ───── Main content ───── */
.main-content {
    margin-left: var(--sidebar-w);
    padding: 2.25rem 2.5rem;
    min-height: 100vh;
}

/* ───── Page Header ───── */
.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--bs-body-color);
    margin: 0 0 .25rem;
}

.page-subtitle {
    font-size: .9rem;
    color: #475569; /* slate-600 */
    margin: 0;
}

/* ───── Stat Cards ───── */
.stat-card {
    border: none;
    border-radius: 1.25rem;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.04), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 4px;
}
.stat-card.card-blue::after { background: linear-gradient(90deg, #3b82f6, #6366f1); }
.stat-card.card-green::after { background: linear-gradient(90deg, #10b981, #059669); }
.stat-card.card-violet::after { background: linear-gradient(90deg, #8b5cf6, #d946ef); }

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    transition: transform 0.3s ease;
}

.stat-card:hover .stat-icon {
    transform: scale(1.1) rotate(5deg);
}

.stat-icon-blue  { background: linear-gradient(135deg, #eff6ff, #dbeafe); color: #2563eb; }
.stat-icon-green { background: linear-gradient(135deg, #ecfdf5, #d1fae5); color: #059669; }
.stat-icon-violet { background: linear-gradient(135deg, #f5f3ff, #ede9fe); color: #7c3aed; }

.stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    line-height: 1.2;
    color: #0f172a;
}

.stat-label {
    font-size: .85rem;
    color: #475569; /* slate-600 */
    font-weight: 500;
}

/* ───── Cards ───── */
.card {
    border: 1px solid var(--bs-border-color);
    border-radius: 1rem;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.05), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
    background: #ffffff;
    transition: all 0.3s ease;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--bs-border-color);
    font-weight: 700;
    padding: 1.25rem 1.5rem;
    font-size: 0.95rem;
    color: var(--bs-body-color);
}

/* ───── Form Controls ───── */
.form-control, .form-select {
    border-radius: 0.75rem;
    border: 1px solid var(--bs-border-color);
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    color: #1e293b; /* slate-800 */
    line-height: 1.5;
    transition: all 0.2s ease;
}

input, select, textarea {
    line-height: 1.5 !important;
}

/* Enforce Sarabun and line-height for all placeholder variants */
::placeholder {
    font-family: 'Sarabun', sans-serif !important;
    line-height: 1.5 !important;
}

.form-control::placeholder {
    font-family: 'Sarabun', sans-serif !important;
    line-height: 1.5 !important;
}

/* Chrome, Safari, Opera */
input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder,
.form-control::-webkit-input-placeholder {
    font-family: 'Sarabun', sans-serif !important;
    line-height: 1.5 !important;
}

/* Firefox */
input::-moz-placeholder,
textarea::-moz-placeholder,
.form-control::-moz-placeholder {
    font-family: 'Sarabun', sans-serif !important;
    line-height: 1.5 !important;
}

/* IE/Edge */
input:-ms-input-placeholder,
textarea:-ms-input-placeholder,
.form-control:-ms-input-placeholder {
    font-family: 'Sarabun', sans-serif !important;
    line-height: 1.5 !important;
}

.form-control-lg, .form-select-lg {
    padding: 0.8rem 1.25rem !important; /* slightly more padding for mobile large inputs */
    font-size: 1.1rem !important;
    line-height: 1.6 !important;
}

.form-control:focus, .form-select:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.btn {
    border-radius: 0.75rem;
    padding: 0.625rem 1.25rem;
    font-weight: 600;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    font-size: 0.92rem;
}

.btn-primary {
    background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.18);
    color: #fff;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4338ca 0%, #2563eb 100%);
    transform: translateY(-1.5px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.25);
}

.btn-primary:active {
    transform: translateY(0);
}

/* ───── Tables ───── */
.table > thead th {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--bs-body-color);
    background-color: #f8fafc;
    border-bottom: 2px solid var(--bs-border-color);
    white-space: nowrap;
    padding: 1rem 1.25rem;
}

.table > tbody td {
    padding: 1rem 1.25rem;
    vertical-align: middle;
    font-size: .92rem;
    color: var(--bs-body-color);
    border-bottom: 1px solid var(--bs-border-color);
}

.table-hover > tbody > tr:hover {
    background-color: #f1f5f9; /* slate-100 */
}

/* ───── Badges ───── */
.badge-admin {
    background: #e0e7ff;
    color: #4338ca;
    border: 1px solid #c7d2fe;
    font-weight: 600;
    padding: 0.35em 0.85em;
    border-radius: 2rem;
    font-size: 0.82rem;
}

.badge-teacher {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    font-weight: 600;
    padding: 0.35em 0.85em;
    border-radius: 2rem;
    font-size: 0.82rem;
}

.badge-director {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    font-weight: 600;
    padding: 0.35em 0.85em;
    border-radius: 2rem;
    font-size: 0.82rem;
}

/* ───── Welcome Banner ───── */
.welcome-banner {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    border-radius: 1.25rem;
    padding: 2rem;
    color: #fff;
    position: relative;
    overflow: hidden;
    margin-bottom: 1.75rem;
    box-shadow: 0 10px 25px -5px rgba(30, 41, 59, 0.1);
}

.welcome-banner::before {
    content: '';
    position: absolute;
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(255, 255, 255, 0) 70%);
    top: -50px; right: -50px;
    border-radius: 50%;
}

.welcome-banner h2 {
    font-weight: 700;
    margin-bottom: 0.5rem;
    font-size: 1.75rem;
}

/* ───── Login ───── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 10% 20%, #1e1b4b 0%, #0f172a 90%);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
}

.login-wrapper::before, .login-wrapper::after {
    content: '';
    position: absolute;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    z-index: 0;
}

.login-wrapper::before {
    background: #6366f1;
    top: 15%;
    left: 15%;
}

.login-wrapper::after {
    background: var(--gold-accent);
    bottom: 15%;
    right: 15%;
}

.login-card {
    width: 100%;
    max-width: 410px;
    border-radius: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: fadeUp .6s cubic-bezier(0.16, 1, 0.3, 1) both;
    z-index: 1;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-logo {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, #312e81, #4f46e5);
    border-radius: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #fff;
    margin: 0 auto 1.25rem;
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.3);
}

/* ───── Login Action Buttons ───── */
.btn.btn-checkin {
    background: linear-gradient(135deg, #f59e0b, #eab308) !important;
    color: #1e1b4b !important;
    border: none !important;
    border-radius: .75rem;
    padding: .65rem 1rem;
    font-weight: 700;
    font-size: .9rem;
    transition: all .25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 14px rgba(234, 179, 8, 0.25);
    text-decoration: none !important;
}
.btn.btn-checkin:hover,
.btn.btn-checkin:focus {
    background: linear-gradient(135deg, #d97706, #ca8a04) !important;
    color: #fff !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(234, 179, 8, 0.4);
}
.btn.btn-checkin:active {
    transform: translateY(0);
}

.btn.btn-register {
    background: transparent !important;
    color: #818cf8 !important;
    border: 1.5px solid rgba(129, 140, 248, 0.4) !important;
    border-radius: .75rem;
    padding: .6rem 1rem;
    font-weight: 600;
    font-size: .85rem;
    transition: all .25s cubic-bezier(0.16, 1, 0.3, 1);
    text-decoration: none !important;
}
.btn.btn-register:hover,
.btn.btn-register:focus {
    background: rgba(99, 102, 241, 0.1) !important;
    color: #6366f1 !important;
    border-color: rgba(99, 102, 241, 0.55) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.15);
}
.btn.btn-register:active {
    transform: translateY(0);
}

/* ───── Confirm Delete ───── */
.confirm-card {
    max-width: 440px;
    margin: 3rem auto;
    text-align: center;
    border: none;
    border-radius: 1.25rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.confirm-icon {
    width: 60px; height: 60px;
    background: #fef2f2;
    color: #ef4444;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 1.25rem;
}

/* ───── Toolbar ───── */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .85rem;
    margin-bottom: 1.25rem;
}

/* ───── Mobile Responsive ───── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        padding: 1.25rem 1rem;
    }
    .mobile-header {
        display: flex !important;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (min-width: 992px) {
    .mobile-header { display: none !important; }
    .sidebar-overlay { display: none !important; }
}

.mobile-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 1030;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    padding: .75rem 1.25rem;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1035;
}

.sidebar-overlay.show { display: block; }

/* ───── Utilities ───── */
.form-card { max-width: 580px; }
.gap-row { gap: .85rem; }

@media (min-width: 992px) {
    .border-end-lg {
        border-right: 1px solid var(--bs-border-color) !important;
    }
}


/* Smooth page transitions */
.main-content > * {
    animation: fadeIn .45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Scrollbar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

/* ───── Theme Toggle Button ───── */
#themeToggleBtn {
    background-color: #f1f5f9;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

#themeToggleBtn:hover {
    background-color: #e2e8f0;
    transform: scale(1.05);
}

.text-theme {
    color: var(--bs-body-color);
    transition: color 0.2s ease;
}

/* ───── Dark Mode Overrides ───── */
[data-bs-theme="dark"] {
    --bs-body-color: #ffffff; /* Pure white in dark mode for high readability */
    --bs-body-bg: #090d16;
    --bs-secondary-color: #94a3b8; /* slate-400 */
    --bs-border-color: rgba(255, 255, 255, 0.12); /* clean borders in dark theme */
    --bs-border-color-translucent: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .text-theme {
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .mobile-header {
    background: rgba(11, 15, 25, 0.85);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .page-title {
    color: #f8fafc;
}

[data-bs-theme="dark"] .card {
    background: #0f172a;
}

[data-bs-theme="dark"] .card-header {
    color: #f8fafc;
}

[data-bs-theme="dark"] .stat-card {
    background: linear-gradient(145deg, #111827 0%, #0b0f19 100%);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

[data-bs-theme="dark"] .stat-value {
    color: #f8fafc;
}

[data-bs-theme="dark"] .table > thead th {
    background-color: #0b0f19;
    border-bottom-color: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
}

[data-bs-theme="dark"] .table > tbody td {
    color: #cbd5e1;
    border-bottom-color: var(--bs-border-color-translucent);
}

[data-bs-theme="dark"] .table-hover > tbody > tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #1e293b;
    border-color: #475569;
    color: #f8fafc;
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: #64748b;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #1e293b;
    border-color: #818cf8;
    color: #fff;
}

[data-bs-theme="dark"] .confirm-card {
    background: #0f172a;
}

[data-bs-theme="dark"] .btn-outline-dark {
    color: #f8fafc;
    border-color: #475569;
}

[data-bs-theme="dark"] .btn-outline-dark:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #fff;
}

[data-bs-theme="dark"] #themeToggleBtn {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--gold-accent);
}

[data-bs-theme="dark"] #themeToggleBtn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* ───── Responsive Mobile Tables (Global) ───── */
@media (max-width: 767.98px) {
    .table-responsive .table.mobile-card-table, 
    .table-responsive .table.mobile-card-table thead, 
    .table-responsive .table.mobile-card-table tbody, 
    .table-responsive .table.mobile-card-table th, 
    .table-responsive .table.mobile-card-table td, 
    .table-responsive .table.mobile-card-table tr { 
        display: block; 
    }
    
    .table-responsive .table.mobile-card-table thead tr { 
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    
    .table-responsive .table.mobile-card-table tr { 
        border: 1px solid var(--bs-border-color) !important;
        margin-bottom: 1rem;
        border-radius: 0.75rem;
        padding: 0.5rem;
        background: var(--bs-body-bg);
        box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
        overflow: hidden;
    }
    
    .table-responsive .table.mobile-card-table td { 
        border: none;
        border-bottom: 1px dashed var(--bs-border-color-translucent, rgba(0,0,0,0.1));
        position: relative;
        padding: 0.75rem 1rem 0.75rem 45% !important; 
        text-align: right !important;
        min-height: 2.5rem;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    [data-bs-theme="dark"] .table-responsive .table.mobile-card-table td {
        border-bottom-color: rgba(255,255,255,0.1);
    }
    
    .table-responsive .table.mobile-card-table td:last-child {
        border-bottom: 0;
        padding-left: 1rem !important;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .table-responsive .table.mobile-card-table td:last-child::before {
        position: relative;
        left: 0;
        width: auto;
        flex-shrink: 0;
        margin-right: auto;
    }
    
    .table-responsive .table.mobile-card-table td::before { 
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        width: 40%;
        text-align: left;
        font-weight: 600;
        color: var(--bs-secondary-color);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .table-responsive .table.mobile-card-table td > * {
        text-align: right;
    }
}

/* ───── Responsive Calendar (Mobile List View) ───── */
@media (max-width: 767.98px) {
    .calendar-table,
    .calendar-table tbody,
    .calendar-table tr,
    .calendar-table td {
        display: block !important;
        width: 100% !important;
    }
    
    .calendar-table thead {
        display: none !important;
    }
    
    .calendar-table tr {
        display: flex !important;
        flex-direction: column;
    }
    
    .calendar-table td {
        border: none !important;
        border-bottom: 1px solid var(--bs-border-color) !important;
        min-height: auto !important;
        height: auto !important;
        padding: 1.25rem !important;
        position: relative;
    }
    
    /* Hide empty days */
    .calendar-table td.empty-day {
        display: none !important;
    }
    
    /* Make the cell a card style */
    .calendar-table {
        background: transparent !important;
        border: none !important;
    }
    
    .calendar-table td {
        background: var(--bs-body-bg);
        margin-bottom: 0.75rem;
        border-radius: 1rem;
        border: 1px solid var(--bs-border-color) !important;
        box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    }
    
        [data-bs-theme="dark"] .calendar-table td {
        background: var(--bs-body-bg);
        border-color: rgba(255,255,255,0.1) !important;
    }
}

/* Ensure interactive calendar grid (.box-calendar-grid) always displays as a full 7-column month calendar */
.table.box-calendar-grid,
table.box-calendar-grid {
    display: table !important;
    width: 100% !important;
    table-layout: fixed !important;
}
.table.box-calendar-grid thead,
table.box-calendar-grid thead {
    display: table-header-group !important;
}
.table.box-calendar-grid tbody,
table.box-calendar-grid tbody {
    display: table-row-group !important;
}
.table.box-calendar-grid tr,
table.box-calendar-grid tr {
    display: table-row !important;
}
.table.box-calendar-grid th,
.table.box-calendar-grid td,
table.box-calendar-grid th,
table.box-calendar-grid td {
    display: table-cell !important;
    width: 14.2857% !important;
    vertical-align: top !important;
}

/* Dark Mode Text Clarity Overrides */
[data-bs-theme="dark"] .text-secondary,
[data-bs-theme="dark"] .text-muted,
[data-bs-theme="dark"] .page-subtitle,
[data-bs-theme="dark"] small:not(.badge),
[data-bs-theme="dark"] .small:not(.badge) {
    color: #e2e8f0 !important; /* Crisp bright light text */
}

[data-bs-theme="dark"] .text-theme,
[data-bs-theme="dark"] .fw-bold.text-dark,
[data-bs-theme="dark"] h1, 
[data-bs-theme="dark"] h2, 
[data-bs-theme="dark"] h3, 
[data-bs-theme="dark"] h4, 
[data-bs-theme="dark"] h5, 
[data-bs-theme="dark"] h6 {
    color: #ffffff !important; /* Pure solid white */
}
