:root {
    --primary-color: #1d4ed8;
    --primary-gradient: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);
    --secondary-color: #0ea5e9;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-color: #0f172a;
    --light-color: #f8fafc;
    --sidebar-width: 260px;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.4);
    --card-shadow: 0 8px 30px rgb(0 0 0 / 0.04);
}

body {
    background-color: #f1f5f9;
    font-family: 'Candara', Calibri, 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: #334155;
    overflow-x: hidden;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(255, 255, 255, 0.4);
    color: #475569;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.02);
}

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.sidebar-brand {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.25rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-menu {
    padding: 1.5rem 1rem;
    height: calc(100vh - 70px);
    overflow-y: auto;
}

.menu-heading {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

.menu-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem 0;
}

.menu-item {
    margin-bottom: 0.25rem;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #475569;
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    font-weight: 700;
}

.menu-link:hover {
    color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.08);
}

.menu-link.active {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.25);
}

/* Header/Navbar Styling */
.header {
    height: 70px;
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    z-index: 99;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    transition: all 0.3s ease;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Main Content Area */
.main-wrapper {
    margin-left: var(--sidebar-width);
    padding-top: 70px;
    transition: all 0.3s ease;
    min-height: 100vh;
}

.content-container {
    padding: 2rem;
}

/* Glassmorphism Cards */
.card-glass {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-glass:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgb(0 0 0 / 0.06);
}

/* Metric Cards */
.metric-card {
    position: relative;
    overflow: hidden;
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary-color);
}

.metric-card.success .metric-icon { background: rgba(16, 185, 129, 0.08); color: var(--success-color); }
.metric-card.warning .metric-icon { background: rgba(245, 158, 11, 0.08); color: var(--warning-color); }
.metric-card.info .metric-icon { background: rgba(14, 165, 233, 0.08); color: var(--secondary-color); }
.metric-card.danger .metric-icon { background: rgba(239, 68, 68, 0.08); color: var(--danger-color); }

/* Quick Actions & Utilities */
.progress-bar-wrap { min-width: 140px; }

.btn-primary-grad {
    background: var(--primary-gradient);
    border: none;
    color: white;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.25);
    transition: all 0.2s ease;
}

.btn-primary-grad:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
    color: white;
}

/* Table Styling */
.table-responsive-custom {
    border-radius: 0.75rem;
    overflow-x: auto;
    border: 1px solid var(--glass-border);
}

.table-custom {
    margin-bottom: 0;
}

.table-custom th {
    background: rgba(241, 245, 249, 0.6);
    color: #475569;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}

.table-custom td {
    padding: 1rem 1.5rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

/* School Badge styling */
.badge-school {
    padding: 0.35em 0.65em;
    font-size: 0.75em;
    font-weight: 600;
    border-radius: 0.25rem;
}

.school-main-badge { background-color: rgba(37, 99, 235, 0.1); color: var(--primary-color); }
.school-creche-badge { background-color: rgba(14, 165, 233, 0.1); color: var(--secondary-color); }
.school-holiday-badge { background-color: rgba(245, 158, 11, 0.1); color: #f59e0b; }

/* Login Page Styling */
.login-bg {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 480px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 1.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    padding: 3rem;
}

.preset-login-badge {
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-login-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.4s ease forwards;
}

.bg-light-hover {
    background-color: #f8fafc;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.bg-light-hover:hover {
    background-color: #f1f5f9;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

/* Sidebar Dropdowns & Submenus */
.menu-item-dropdown {
    position: relative;
    list-style: none;
}

.menu-link-dropdown {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #475569;
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    font-weight: 700;
    cursor: pointer;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
}

.menu-link-dropdown:hover, .menu-link-dropdown.active {
    color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.08);
}

.menu-link-dropdown .arrow-icon {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
    margin-left: auto;
}

.menu-link-dropdown.open .arrow-icon {
    transform: rotate(180deg);
}

.submenu-list {
    list-style: none;
    padding-left: 1.25rem;
    margin: 0.25rem 0 0.5rem 0;
    display: none; /* Collapsed by default */
}

.submenu-list.open {
    display: block;
}

.submenu-item {
    margin-bottom: 0.15rem;
}

.submenu-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: #475569;
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    font-weight: 600;
}

.submenu-link:hover {
    color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.05);
}

.submenu-link.active {
    color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.1);
    font-weight: 600;
}

/* Responsive media queries & Mobile Optimizations */
* {
    -webkit-tap-highlight-color: rgba(37, 99, 235, 0.1);
}

.table-responsive-custom, .sidebar-menu, body {
    -webkit-overflow-scrolling: touch;
}

.table-responsive-custom::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.table-responsive-custom::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
    border-radius: 10px;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1050;
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.15);
        background: rgba(255, 255, 255, 0.95);
    }

    body.show-sidebar .sidebar {
        transform: translateX(0);
    }
    
    .header {
        left: 0;
        padding: 0 1rem;
        height: 65px;
    }
    
    .main-wrapper {
        margin-left: 0;
        padding-top: 65px;
    }

    .content-container {
        padding: 1rem 0.75rem;
    }
    
    /* Toggle Sidebar Button */
    .sidebar-toggle-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        min-width: 42px;
        min-height: 42px;
        border-radius: 10px;
    }
    
    /* Sidebar Backdrop */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(15, 23, 42, 0.5);
        z-index: 1040;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    body.show-sidebar .sidebar-backdrop {
        display: block;
    }

    /* Table cell padding scaling */
    .table-custom th, .table-custom td {
        padding: 0.75rem 0.75rem !important;
        font-size: 0.85rem;
    }

    /* Login card scaling */
    .login-card {
        padding: 1.75rem 1.25rem !important;
        border-radius: 1.25rem !important;
    }

    .login-bg {
        padding: 1rem 0.5rem !important;
    }

    /* Prevent mobile browser zoom on form focus (iOS Safari bug) */
    .form-control, .form-select, select, input, textarea {
        font-size: 16px !important;
        min-height: 44px;
        border-radius: 10px;
    }

    .btn {
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .btn-sm, .btn-xs {
        min-height: 36px;
    }

    /* Modals Responsive Layout */
    .modal-dialog {
        margin: 0.5rem auto !important;
        max-width: 96% !important;
    }

    .modal-content {
        border-radius: 1.25rem !important;
    }

    .modal-header, .modal-footer {
        padding: 1rem !important;
    }

    .modal-body {
        padding: 1rem !important;
        max-height: 75vh;
        overflow-y: auto;
    }
}

/* Fix Bootstrap Modal Stacking Context & Form Input Interactivity */
.modal-backdrop {
    z-index: 1050 !important;
}

.modal {
    z-index: 1060 !important;
}

.modal-dialog {
    z-index: 1070 !important;
    position: relative;
}

.modal-content {
    background-color: #ffffff !important;
    position: relative;
    z-index: 1080 !important;
    pointer-events: auto !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
}

.modal-header, .modal-body, .modal-footer, .modal input, .modal select, .modal textarea, .modal button {
    pointer-events: auto !important;
    position: relative;
    z-index: 1090 !important;
}

@media (max-width: 767.98px) {
    .header {
        padding: 0 0.75rem;
    }

    .header-school-name {
        display: none !important;
    }

    .header form select {
        max-width: 150px !important;
        font-size: 0.75rem !important;
    }

    /* Card Padding on Small Mobile */
    .card-glass {
        padding: 1.25rem 1rem !important;
        border-radius: 1rem;
    }

    /* Action Toolbar Button Stacking */
    .d-flex.flex-wrap.justify-content-between {
        flex-direction: column;
        align-items: stretch !important;
    }

    .d-flex.flex-wrap.justify-content-between > div {
        width: 100%;
    }

    .d-flex.flex-wrap.justify-content-between > .d-flex {
        flex-wrap: wrap;
        width: 100%;
        margin-top: 0.75rem;
    }

    .d-flex.flex-wrap.justify-content-between > .d-flex .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    /* Metric Cards Grid Fix */
    .metric-card {
        margin-bottom: 0.75rem;
    }

    /* Table Badges & Action Buttons Spacing */
    .table-custom td .d-flex {
        gap: 0.35rem !important;
    }

    .table-custom td .btn-sm {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 575.98px) {
    .content-container {
        padding: 0.75rem 0.5rem;
    }

    /* Topbar Header Compact Layout */
    .header {
        height: 60px;
    }

    .main-wrapper {
        padding-top: 60px;
    }

    .sidebar-brand span {
        font-size: 1.1rem;
    }

    .header form select {
        max-width: 130px !important;
    }

    /* Filter Buttons Full Width */
    .btn-group.btn-group-sm {
        width: 100%;
    }

    .btn-group.btn-group-sm .btn {
        flex: 1;
        font-size: 0.75rem;
        padding: 0.35rem 0.25rem;
    }

    /* Table custom mobile touch text size */
    .table-custom th {
        font-size: 0.7rem;
        padding: 0.6rem 0.5rem !important;
    }
    .table-custom td {
        font-size: 0.8rem;
        padding: 0.6rem 0.5rem !important;
    }
}

