/* 
 * School Management System - Main Style
 * Theme: Modern Admin - Blue Accents
 */

:root {
    /* Primary Colors */
    --primary-color: #4361EE;
    --primary-hover: #3749CC;
    --primary-dark: #1E293B;
    --primary-accent: #4361EE;
    
    /* Semantic Colors */
    --success-color: #10B981;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;
    --info-color: #3B82F6;
    
    /* Neutral Colors */
    --bg-light: #F8F9FC;
    --bg-white: #FFFFFF;
    --text-dark: #1E293B;
    --text-muted: #64748B;
    --border-color: #E2E8F0;
    

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-dark);
    font-size: 0.875rem;
    overflow-x: hidden;
    background-color: var(--bg-light);
}

/* Print Utilities */
@media print {
    .no-print { display: none !important; }
    .card { box-shadow: none !important; border: 1px solid #eee !important; }
    .container-fluid { padding: 0 !important; margin: 0 !important; width: 100% !important; max-width: 100% !important; }
    .sidebar, #sidebar, .topbar, .btn, .modal-footer, .breadcrumb, .no-print { display: none !important; }
    #content { margin: 0 !important; padding: 0 !important; width: 100% !important; }
    body { background: white !important; }
}

.border-dashed { border-style: dashed !important; }

/* --- Layout Structure --- */
.wrapper {
    display: flex;
    align-items: stretch;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    position: relative; /* Base for z-index layering */
}

/* Auth Pages */
.auth-page {
    background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%) !important;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    background: white;
    padding: 3rem 2.5rem;
    border-radius: 1.25rem !important;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 420px;
}

#sidebar {
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    background-color: var(--primary-dark) !important;
    color: #fff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

#sidebar .sidebar-content {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
}

#sidebar .sidebar-content::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

#sidebar.active {
    min-width: 80px;
    max-width: 80px;
}

#sidebar.active .sidebar-header {
    flex-direction: column;
    padding: 1.25rem 0.5rem !important;
    justify-content: center !important;
    text-align: center;
}

#sidebar.active .sidebar-header .bg-primary-accent {
    margin-right: 0 !important;
    margin-bottom: 0.75rem;
    width: 40px !important;
    height: 40px !important;
}

#sidebar.active .sidebar-header span,
#sidebar.active .nav-link span,
#sidebar.active small {
    display: none !important;
}

#sidebar.active #sidebarCollapse {
    padding: 0.5rem !important;
    margin-top: 0.5rem;
}

#sidebar.active .nav-link {
    text-align: center;
    padding: 0.75rem 0 !important;
    justify-content: center !important;
    border-radius: 0.75rem !important;
    margin: 4px 10px !important;
    width: auto !important;
}

#sidebar.active .nav-link i {
    margin-right: 0 !important;
    margin-left: 0 !important;
    font-size: 1.4rem;
    display: block;
}

#sidebar.active .sidebar-content {
    padding: 10px !important;
}

#sidebar.active .nav-item.active .nav-link {
    box-shadow: 0 4px 10px rgba(67, 97, 238, 0.4);
}

#content {
    background: transparent;
    transition: all 0.3s;
    width: 100%;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Ensure dropdowns aren't clipped by responsive tables */
.table-responsive {
    overflow: visible !important;
}

@media (max-width: 991.98px) {
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 60px; /* Space for dropdowns at the bottom */
        margin-bottom: -60px;
    }
}

/* --- Sidebar Navigation links --- */
#sidebar .nav-link {
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    color: #94a3b8 !important;
    padding: 0.75rem 1rem !important;
    border-radius: 0.75rem !important;
    margin: 2px 0;
}

#sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #fff !important;
    transform: translateX(4px);
}

#sidebar .active > .nav-link,
#sidebar .nav-item.active .nav-link {
    background-color: var(--primary-accent) !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.25);
}

#sidebar .nav-link i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

#sidebar.active .nav-link:hover {
    transform: none !important;
    background-color: var(--primary-accent) !important;
}

/* --- Card / Content nav-pills (tabs in forms, config, etc.) --- */
.card .nav-pills .nav-link,
.card-header .nav-pills .nav-link {
    color: #64748b !important;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
    padding: 0.5rem 1.25rem !important;
    border-radius: 2rem !important;
    margin: 0;
    background: transparent;
}

.card .nav-pills .nav-link:hover,
.card-header .nav-pills .nav-link:hover {
    background-color: #f1f5f9 !important;
    color: #1e293b !important;
    transform: none !important;
}

.card .nav-pills .nav-link.active,
.card-header .nav-pills .nav-link.active {
    background-color: var(--primary-accent) !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.25);
}

.tracking-widest { letter-spacing: 0.1em; }
.tracking-wider { letter-spacing: 0.05em; }

/* --- Components --- */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* --- Backgrounds & Utilites --- */
.bg-primary-accent { background-color: var(--primary-accent) !important; }
.text-dark-blue { color: #0F172A !important; }

/* Soft Backgrounds */
.bg-soft-primary   { background-color: #E0E7FF !important; color: #4361EE !important; }
.bg-soft-success   { background-color: #D1FAE5 !important; color: #065F46 !important; }
.bg-soft-danger    { background-color: #FEE2E2 !important; color: #991B1B !important; }
.bg-soft-warning   { background-color: #FFFBEB !important; color: #92400E !important; }
.bg-soft-info      { background-color: #F0F9FF !important; color: #075985 !important; }
.bg-soft-secondary { background-color: #F8FAFC !important; color: #475569 !important; }

/* Typography */
.fs-9 { font-size: 0.65rem !important; }
.fs-8 { font-size: 0.75rem !important; }
.fs-7 { font-size: 0.8rem !important; }
.tracking-widest { letter-spacing: 0.15em !important; }
.tracking-wider  { letter-spacing: 0.05em !important; }

.icon-shape { 
    width: 48px; 
    height: 48px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}

/* --- Components --- */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-soft-primary {
    background-color: #4361EE15 !important;
    color: #4361EE !important;
    border: none !important;
}

.btn-soft-primary:hover {
    background-color: #4361EE !important;
    color: white !important;
}

.btn-dark-blue {
    background-color: #1E293B !important;
    color: white !important;
}

.btn-dark-blue:hover {
    background-color: #0F172A !important;
    color: white !important;
}

.rounded-3 { border-radius: 0.75rem !important; }
.rounded-4 { border-radius: 1rem !important; }
.rounded-5 { border-radius: 1.5rem !important; }

.search-item { transition: background 0.2s; }
.search-item:hover { background-color: #F8F9FF !important; }

.tracking-wider    { letter-spacing: 0.05em !important; }
.tracking-widest   { letter-spacing: 0.1em !important; }

.opacity-10 { opacity: 0.1; }

.topbar-divider {
    width: 0;
    border-right: 1px solid #e3e6f0;
    height: calc(var(--topbar-height) - 32px);
    margin: auto 1rem;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* --- Mobile & Tablet App-like UI (Max-width: 991.98px) --- */
@media (max-width: 991.98px) {
    :root {
        --topbar-height: 56px;
    }

    body {
        font-size: 0.825rem; /* Slightly smaller base font on mobile */
    }

    .container-fluid {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .wrapper {
        display: block;
        height: auto;
        overflow: visible;
    }

    #content {
        padding-bottom: 90px; /* Extra space for bottom nav */
    }

    /* Fixed topbar glassmorphism */
    .topbar {
        height: var(--topbar-height);
        position: sticky;
        top: 0;
        z-index: 1030;
        backdrop-filter: blur(8px);
        background: rgba(255, 255, 255, 0.9) !important;
    }

    #sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 285px;
        height: 100vh;
        z-index: 2000 !important; /* Force sidebar to very top */
        transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 15px 0 35px rgba(0,0,0,0.15);
        margin-left: 0 !important;
        border-radius: 0 1.5rem 1.5rem 0;
        overflow-y: auto;
    }

    #sidebar.show {
        left: 0;
    }

    #mobileBackdrop {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(15, 23, 42, 0.5);
        backdrop-filter: blur(4px);
        z-index: 1055;
        transition: opacity 0.3s ease;
    }

    /* --- Table to List-Card Transformation --- */
    .mobile-app-table thead {
        display: none;
    }
    .mobile-app-table tr {
        display: block;
        background: #fff;
        border-radius: 1rem;
        margin-bottom: 1rem !important;
        padding: 1.25rem !important;
        box-shadow: 0 4px 12px rgba(0,0,0,0.05) !important;
        border: 1px solid rgba(0,0,0,0.02);
    }
    .mobile-app-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.65rem 0 !important;
        border: none !important;
        text-align: right;
        font-size: 0.85rem;
    }
    .mobile-app-table td::before {
        content: attr(data-label);
        font-weight: 700;
        text-transform: uppercase;
        font-size: 0.6rem;
        color: var(--text-muted);
        letter-spacing: 0.08em;
        text-align: left;
    }
    /* Action cell handling */
    .mobile-app-table td:last-child {
        justify-content: flex-end;
        padding-top: 1rem !important;
        border-top: 1px solid #f1f5f9 !important;
        margin-top: 0.75rem;
    }
    .mobile-app-table td:last-child::before {
        display: none;
    }

    /* --- Bottom Sheet Modals --- */
    .modal-dialog {
        margin: 0;
        position: fixed;
        bottom: 0;
        width: 100%;
        max-width: 100% !important;
    }
    .modal.fade .modal-dialog {
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .modal.show .modal-dialog {
        transform: translateY(0);
    }
    .modal-content {
        border-radius: 1.5rem 1.5rem 0 0 !important;
        border: none;
        max-height: 90vh;
        overflow-y: auto;
        padding-bottom: env(safe-area-inset-bottom, 30px);
        box-shadow: 0 -10px 25px rgba(0,0,0,0.1);
    }
    .modal-header {
        border-bottom: 1.5px solid #f1f5f9;
        padding: 1.25rem 1.5rem;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .modal-header::before {
        content: '';
        width: 40px;
        height: 5px;
        background: #e2e8f0;
        border-radius: 10px;
        margin-bottom: 1rem;
    }

    /* Floating Action Button (FAB) */
    .fab-container {
        position: fixed;
        bottom: 85px; /* Above bottom nav */
        right: 20px;
        z-index: 1035;
    }
    .btn-fab {
        width: 56px;
        height: 56px;
        border-radius: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 10px 25px rgba(67, 97, 238, 0.4);
        font-size: 1.5rem;
        padding: 0;
    }

    /* --- Dashboard Specific --- */
    .dashboard-kpi {
        padding: 1rem !important;
    }
    .dashboard-kpi .icon-shape {
        width: 40px;
        height: 40px;
        padding: 0.5rem !important;
    }
    .dashboard-kpi .h4 {
        font-size: 1.15rem !important;
    }

    /* Filters: stack on mobile */
    .card-body form .row > div {
        margin-bottom: 1rem;
    }

    /* --- Responsive Utilities --- */
    .mobile-stack {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }
    .mobile-wrap {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }
    .mobile-center {
        text-align: center !important;
        justify-content: center !important;
        align-items: center !important;
    }

    /* Target specific containers to avoid global breakages */
    .card-header.d-flex, .glass-header.d-flex {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem;
    }

    .topbar .d-flex.align-items-center {
        max-width: 65%;
    }

    /* Button and Input adjustments */
    .btn:not(.btn-sm):not(.w-md-auto) {
        width: 100%;
    }
    .btn-group .btn {
        width: auto !important;
    }
}

/* --- Premium Aesthetics --- */
.bg-primary-accent {
    background: linear-gradient(135deg, #4361EE 0%, #304FFE 100%) !important;
}

.card {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    border: 1px solid rgba(0,0,0,0.05);
}

@media (min-width: 992px) {
    .card:hover {
        transform: translateY(-6px);
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.12) !important;
    }
}

/* Glassmorphism */
.glass-card {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}

.glass-header {
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(10px);
    z-index: 1020;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.modal {
    z-index: 2010 !important;
    pointer-events: none; /* Let clicks pass through to backdrop when not on dialog */
}

.modal-backdrop {
    background-color: #0f172a !important;
    opacity: 0.4 !important;
    backdrop-filter: blur(4px);
    z-index: 2000 !important;
}

.modal-dialog {
    z-index: 2011 !important;
    pointer-events: auto !important; /* Force interaction on the dialog itself */
}

.modal-content {
    pointer-events: auto !important;
    z-index: 2012 !important;
}

/* Base for z-index layering - REMOVED z-index as it traps modals under backdrops */
.wrapper {
    position: relative;
}

/* Soft Color Utilities */
.bg-soft-primary   { background-color: rgba(67, 97, 238, 0.08) !important;  color: #4361ee !important; }
.bg-soft-success   { background-color: rgba(34, 197, 94, 0.08) !important;  color: #22c55e !important; }
.bg-soft-warning   { background-color: rgba(251, 191, 36, 0.08) !important; color: #b45309 !important; }
.bg-soft-info      { background-color: rgba(6, 182, 212, 0.08) !important;  color: #0891b2 !important; }
.bg-soft-danger    { background-color: rgba(239, 68, 68, 0.08) !important;  color: #ef4444 !important; }
.bg-soft-secondary { background-color: rgba(100, 116, 139, 0.08) !important; color: #64748b !important; }
.bg-soft-indigo    { background-color: rgba(99, 102, 241, 0.08) !important; color: #6366f1 !important; }

.text-dark-blue { color: #1e293b !important; }
.text-indigo    { color: #6366f1 !important; }

/* Shadow Tokens */
.shadow-premium {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02) !important;
}
.shadow-soft {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03) !important;
}
.shadow-soft-sm {
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06) !important;
}

/* Helpers */
.transition-all { transition: all 0.3s ease !important; }
.hover-lift:hover { transform: translateY(-4px); }
.hover-scale:hover { transform: scale(1.05); }
.hover-soft-bg:hover { background-color: rgba(0,0,0,0.02); }
.cursor-pointer { cursor: pointer; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes pulseGentle { 0% { transform: scale(1); } 50% { transform: scale(1.03); } 100% { transform: scale(1); } }

.animate-fade-in { animation: fadeIn 0.4s ease-out; }
.animate-slide-up { animation: slideUp 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94); }
.animate-pulse-gentle { animation: pulseGentle 2s infinite ease-in-out; }

/* Table Content & Overflow Fixes */
.table-responsive-premium {
    overflow-x: auto;
    scrollbar-width: thin;
    padding-bottom: 1rem;
    margin-bottom: -1rem;
}

.table-premium {
    min-width: 900px;
    border-collapse: separate;
    border-spacing: 0 8px;
}

.table-premium th {
    background: transparent !important;
    white-space: nowrap;
}

.table-premium td {
    white-space: nowrap;
}

.table-premium .IDENTITY-cell {
    min-width: 240px;
}

.glass-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Button & Nav polish */
.btn-primary {
    box-shadow: 0 4px 14px 0 rgba(67, 97, 238, 0.39);
    transition: all 0.2s ease;
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(67, 97, 238, 0.23);
}

.nav-link i {
    transition: transform 0.2s ease;
}
.nav-link:hover i {
    transform: scale(1.1);
}

.auth-card {
    animation: slideUp 0.7s cubic-bezier(0.19, 1, 0.22, 1);
}

/* --- Global Glass Utilities --- */
.glass-switch {
    width: 3.2rem !important;
    height: 1.6rem !important;
    background-color: rgba(0, 0, 0, 0.05) !important;
    border: 1.5px solid rgba(0, 0, 0, 0.1) !important;
    cursor: pointer;
    transition: all 0.3s ease;
}

.glass-switch:checked {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.glass-input-premium {
    background: rgba(255, 255, 255, 0.5) !important;
    border: 1.5px solid rgba(0, 0, 0, 0.05) !important;
    color: var(--text-dark) !important;
    border-radius: 12px !important;
    padding: 12px 16px !important;
    transition: all 0.3s ease;
}

.glass-input-premium:focus {
    background: #fff !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.1) !important;
    outline: none;
}

.permission-item {
    transition: all 0.2s ease;
    border: 1px solid rgba(0, 0, 0, 0.03) !important;
    background: rgba(255, 255, 255, 0.4) !important;
}

.permission-item:hover {
    background: #fff !important;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.03) !important;
    border-color: var(--primary-color) !important;
}

/* --- Harmonization Utilities --- */
.page-sentinel {
    margin-bottom: 2.5rem;
}

.breadcrumb-premium {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
}

.breadcrumb-premium a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb-premium a:hover {
    color: var(--primary-color);
}

.breadcrumb-premium .active {
    color: var(--primary-color);
    opacity: 0.8;
}

.info-block-label {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    opacity: 0.6;
}

.info-block-label i {
    font-size: 1rem;
    margin-right: 0.75rem;
    color: var(--primary-color);
    opacity: 0.8;
}

.card-title-premium {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    letter-spacing: -0.01em;
}

.form-group-premium {
    margin-bottom: 1.5rem;
}

.form-group-premium label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    display: block;
}

.table-index-col { width: 50px; }
.table-identity-col { min-width: 300px; }
.table-status-col { width: 120px; }
.table-actions-col { width: 100px; }

@media (min-width: 992px) {
    .max-w-1400 { max-width: 1400px; margin-left: auto; margin-right: auto; }
}
