/* Global Variables & Reset */
:root {
    --bg-main: #FAFBFC;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --accent-blue: #3B82F6;
    --accent-green: #10B981;
    --accent-purple: #8B5CF6;
    --white: #FFFFFF;
    --border-light: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transition: all 0.3s ease;
    
    /* App Specific Overrides */
    --app-bg: #F8F9FE;
    --primary: #A288F8;
    --primary-dark: #8B6CEB;
    --secondary: #FF9F43;
    --text-dark: #2D3142;
    --text-muted: #9098B1;
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.4);
    --shadow-lg: 0 10px 25px rgba(162, 136, 248, 0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Nunito', sans-serif; -webkit-tap-highlight-color: transparent !important; }
a, button, input, select, textarea, .menu-item, .cf-item, .dir-list-btn { outline: none !important; }
body { background-color: var(--bg-main); color: var(--text-primary); line-height: 1.6; }
.hide { display: none !important; }

/* Subtle UI Animations */
.fade-in { animation: fadeIn 0.3s ease forwards; opacity: 0; }
@keyframes fadeIn { to { opacity: 1; transform: translateY(0); } }
.fade-scale { animation: fadeScale 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.2) forwards; opacity: 0; transform: scale(0.95); }
@keyframes fadeScale { to { opacity: 1; transform: scale(1); } }
.profile-overlay { animation: slideInUp 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.2) forwards; }
@keyframes slideInUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.full-screen-overlay { animation: slideInRight 0.3s cubic-bezier(0.175, 0.885, 0.32, 1) forwards; }
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* APP CONTAINER */
.app-container { width: 100%; max-width: 480px; min-height: 100dvh; background-color: var(--app-bg); margin: 0 auto; position: relative; box-shadow: 0 0 40px rgba(0,0,0,0.1); overflow-x: hidden; padding-bottom: 100px; color: var(--text-dark); }
.app-container .header { padding: 24px 24px 10px; display: flex; justify-content: space-between; align-items: center; }
.app-container .greeting h1 { font-size: 1.4rem; font-weight: 800; color: var(--text-dark); margin: 0; }
.app-container .greeting p { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; margin: 0; }
.app-container .profile-pic { width: 45px; height: 45px; background: var(--secondary); border-radius: 14px; display: flex; align-items: center; justify-content: center; color: var(--white); font-weight: 800; font-size: 1.1rem; box-shadow: 0 4px 10px rgba(255, 159, 67, 0.3); }

/* HERO CARD (CLASSES) */
.hero-card { margin: 16px 24px; background: linear-gradient(135deg, #B19BFF 0%, #9074F1 100%); border-radius: 24px; padding: 24px; color: var(--white); box-shadow: var(--shadow-lg); position: relative; overflow: hidden; }
.hero-card::after { content: ''; position: absolute; top: -30px; right: -30px; width: 120px; height: 120px; background: rgba(255,255,255,0.1); border-radius: 50%; }
.hero-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; position: relative; z-index: 2; }
.hero-header h2 { font-size: 1.1rem; font-weight: 800; margin: 0; }
.add-class-btn { background: rgba(255,255,255,0.25); border: 1px solid rgba(255,255,255,0.4); color: var(--white); padding: 6px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; cursor: pointer; backdrop-filter: blur(5px); transition: transform 0.2s; }
.add-class-btn:active { transform: scale(0.95); }
.add-class-btn.hidden { display: none; }
.class-list { display: flex; flex-direction: column; gap: 10px; position: relative; z-index: 2; }
.class-row { background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.2); padding: 12px 16px; border-radius: 16px; display: flex; justify-content: space-between; align-items: center; backdrop-filter: blur(8px); }
.class-name { font-size: 0.9rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.class-count { background: var(--white); color: var(--primary-dark); padding: 4px 10px; border-radius: 12px; font-size: 0.8rem; font-weight: 800; }

/* MAIN MENU GRID */
.section-title { margin: 24px 24px 12px; font-size: 1rem; font-weight: 800; color: var(--text-dark); }
.menu-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; padding: 0 24px; }
.menu-item { display: flex; flex-direction: column; align-items: center; gap: 8px; text-decoration: none; cursor: pointer; }
.menu-icon { width: 54px; height: 54px; border-radius: 18px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; background: var(--white); box-shadow: 0 6px 0 rgba(0,0,0,0.1), 0 8px 15px rgba(0,0,0,0.08), inset 0 2px 0 rgba(255,255,255,0.6) !important; transition: all 0.1s ease !important; border: none !important; }
.menu-item:active .menu-icon { transform: translateY(4px) !important; box-shadow: 0 2px 0 rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.08), inset 0 2px 0 rgba(255,255,255,0.6) !important; }
.menu-label { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); text-align: center; line-height: 1.2; }

.ic-att { color: #4FC3F7; background: #EAF7FF; }
.ic-rec { color: #FF9F43; background: #FFF3E8; }
.ic-res { color: #A288F8; background: #F2EFFF; }
.ic-col { color: #51E2C2; background: #E8FCF8; }
.ic-bdy { color: #FF6B6B; background: #FFE8ED; }
.ic-rem { color: #FDCB6E; background: #FFF9EB; }
.ic-his { color: #9098B1; background: #F4F5F7; }

/* ══ FLOATING PILL BOTTOM NAVIGATION ══ */
.bottom-nav {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 420px;
    height: 70px;
    background: var(--white);
    border-radius: 35px;
    box-shadow: 0 10px 35px rgba(162, 136, 248, 0.15);
    z-index: 9999 !important;
    padding: 0 15px;
}

/* Modifies the overlay so it sits flush to the bottom */
.full-screen-overlay, .profile-overlay {
    bottom: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.bottom-nav ul {
    display: flex; list-style: none; padding: 0; margin: 0; 
    height: 100%; align-items: center; justify-content: space-between;
}

.bottom-nav li {
    display: flex; justify-content: center; align-items: center;
    flex: 1; height: 100%;
}

.bottom-nav li a {
    display: flex; justify-content: center; align-items: center;
    width: 48px; height: 48px; 
    color: var(--text-muted); 
    font-size: 1.3rem; 
    transition: all 0.3s ease;
    text-decoration: none;
    border-radius: 50%;
}

.bottom-nav li.active a {
    background-color: rgba(162, 136, 248, 0.15); 
    color: var(--primary-dark);
    transform: scale(1.05);
}

/* Loading Overlay */
#loader { position: absolute; inset: 0; background: var(--app-bg); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 9999; transition: opacity 0.4s; }
.spinner { width: 40px; height: 40px; border: 4px solid rgba(162,136,248,0.2); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================= */
/* ══ THE SCROLLING FIX (APPLIES TO ALL OVERLAYS) ══ */
/* ================================================================= */

/* 1. The wrapper holds the structure but DOES NOT scroll */
.profile-overlay { 
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: 88vh; 
    background: var(--app-bg); z-index: 2000; 
    display: flex; flex-direction: column; 
    border-radius: 30px 30px 0 0; box-shadow: 0 -10px 40px rgba(162, 136, 248, 0.2); 
    max-width: 480px; margin: 0 auto; 
    overflow: hidden; /* Prevents background scrolling */
}

.full-screen-overlay { 
    position: fixed; inset: 0; background: var(--app-bg); z-index: 3000; 
    display: flex; flex-direction: column; 
    max-width: 480px; margin: 0 auto; 
    overflow: hidden; /* Prevents background scrolling */
}

/* 2. The Header stays locked at the top */
.drag-handle { width: 45px; height: 5px; background: #CBD5E1; border-radius: 10px; margin: 14px auto 0; flex-shrink: 0; }
.profile-header { 
    display: flex; align-items: center; gap: 16px; 
    padding: 16px 24px; background: var(--app-bg); 
    border-bottom: none; flex-shrink: 0; z-index: 10; 
}
.profile-header h2 { font-size: 1.2rem; font-weight: 800; margin: 0; }
.icon-btn { background: none; border: none; font-size: 1.2rem; color: var(--text-dark); cursor: pointer; }

/* 3. The Content Area handles 100% of the scrolling natively */
.profile-content { 
    padding: 24px; 
    flex: 1; /* Takes up remaining height */
    overflow-y: auto; /* Enables native scrolling */
    -webkit-overflow-scrolling: touch; /* Enables smooth iOS scrolling */
    padding-bottom: 180px !important; /* Massive padding to ensure the last student clears the bottom nav bar */
}

/* ================================================================= */

.profile-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 30px; }
.stat-box { background: var(--white); border-radius: 16px; padding: 16px; text-align: center; border: 1px solid var(--border-light); box-shadow: var(--shadow-sm); }
.stat-icon { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 8px; font-size: 1.1rem; }
.stat-box h3 { font-size: 1.4rem; font-weight: 800; color: var(--text-dark); margin: 0; line-height: 1.2; }
.stat-box p { font-size: 0.75rem; color: var(--text-muted); font-weight: 700; margin: 0; text-transform: uppercase; }

.btn-primary { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: var(--white); border: none; padding: 16px; border-radius: 16px; font-size: 1.05rem; font-weight: 800; display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 20px rgba(162, 136, 248, 0.3); width: 100%; position: relative; cursor: pointer; transition: transform 0.1s; }
.btn-primary:active { transform: scale(0.96); }
.btn-primary .spinner { position: absolute; width: 24px; height: 24px; border: 3px solid rgba(255,255,255,0.3); border-top-color: var(--white); border-radius: 50%; animation: spin 1s linear infinite; }
.btn-danger { background: #FEF2F2; color: #EF4444; border: 1px solid #FCA5A5; padding: 14px 20px; border-radius: 12px; font-weight: 700; font-size: 1rem; cursor: pointer; transition: all 0.2s; }
.btn-danger:active { background: #FEE2E2; transform: scale(0.98); }

/* MOBILE-FRIENDLY INPUTS */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 800; color: var(--text-dark); margin-bottom: 8px; padding-left: 4px; }
.form-input { width: 100%; padding: 16px; border: 2px solid #E2E8F0; border-radius: 16px; font-size: 1rem; font-weight: 700; color: var(--text-dark); background: var(--white); transition: all 0.2s; -webkit-appearance: none; font-family: 'Nunito', sans-serif; }
.form-input:focus { border-color: var(--primary); box-shadow: 0 4px 15px rgba(162,136,248,0.15); outline: none; }

/* Interactive Subject Chips */
.subject-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.chip-label { padding: 8px 16px; background: var(--white); border: 1.5px solid var(--border-light); border-radius: 20px; font-size: 0.85rem; font-weight: 700; color: var(--text-muted); cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); user-select: none; }
.chip-checkbox { display: none; }
.chip-checkbox:checked + .chip-label { background: var(--primary); color: var(--white); border-color: var(--primary-dark); box-shadow: 0 4px 12px rgba(162, 136, 248, 0.35); transform: translateY(-2px); }
.chip-checkbox:disabled:not(:checked) + .chip-label { opacity: 0.4; cursor: not-allowed; background: #F1F5F9; }
.success-toast { background: #ECFDF5; color: #10B981; padding: 12px; border-radius: 12px; font-size: 0.85rem; font-weight: 700; text-align: center; border: 1px solid #A7F3D0; margin-top: 15px; animation: fadeIn 0.3s ease; }

/* DIRECTORY */
.dir-list-btn { background: var(--white); border: 1px solid var(--border-light); padding: 18px 20px; border-radius: 16px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; cursor: pointer; box-shadow: var(--shadow-sm); width: 100%; text-align: left; }
.dir-list-btn:active { transform: scale(0.97); }
.dir-list-name { font-size: 1rem; font-weight: 800; color: var(--text-dark); }
.dir-list-arrow { color: #CBD5E1; font-size: 1.2rem; }

/* Student Detail Card */
.student-detail-card { background: var(--white); border-radius: 20px; padding: 24px; text-align: center; border: 1px solid var(--border-light); box-shadow: var(--shadow-md); }
.sd-avatar { width: 64px; height: 64px; border-radius: 20px; background: linear-gradient(135deg, #B19BFF 0%, #9074F1 100%); color: var(--white); font-size: 1.8rem; font-weight: 800; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; box-shadow: 0 8px 15px rgba(162, 136, 248, 0.3); }
.student-detail-card h3 { font-size: 1.5rem; font-weight: 800; color: var(--text-dark); margin-bottom: 4px; }
.sd-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; background: #F8FAFC; padding: 12px; border-radius: 12px; margin-top: 15px; text-align: left; }
.sd-info-item { display: flex; flex-direction: column; gap: 4px; }
.sd-info-item span { font-size: 0.7rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; }
.sd-info-item strong { font-size: 0.9rem; color: var(--text-dark); font-weight: 800; }
.history-card { background: var(--white); border-radius: 16px; padding: 16px; border: 1px solid var(--border-light); display: flex; align-items: center; gap: 16px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.hc-icon { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.hc-text h4 { font-size: 0.95rem; font-weight: 800; color: var(--text-dark); margin-bottom: 2px; }
.hc-text p { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; margin: 0; }

/* ATTENDANCE UI */
.att-row { background: var(--white); border: 1px solid var(--border-light); border-radius: 18px; padding: 14px 16px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow-sm); transition: all 0.2s; }
.att-student-info { display: flex; align-items: center; gap: 12px; }
.att-avatar { width: 36px; height: 36px; border-radius: 10px; background: #F1F5F9; color: var(--primary-dark); font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; }
.att-student-name { font-weight: 800; color: var(--text-dark); font-size: 0.95rem; }
.att-toggles { display: flex; gap: 6px; background: #F1F5F9; padding: 4px; border-radius: 14px; }
.att-btn { width: 38px; height: 38px; border-radius: 10px; border: none; font-weight: 800; font-size: 1rem; cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); background: transparent; color: var(--text-muted); }
.att-btn.active.p-btn { background: #10B981; color: white; box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3); transform: scale(1.05); }
.att-btn.active.a-btn { background: #EF4444; color: white; box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3); transform: scale(1.05); }
.att-row.disabled { opacity: 0.8; background: #F8FAFC; }
.att-row.disabled .att-toggles { pointer-events: none; }

/* FEE RECEIPT & RADIO CHIPS */
.radio-chip { flex: 1; text-align: center; }
.radio-chip input[type="radio"] { display: none; }
.radio-chip span { display: block; padding: 12px 10px; background: #F1F5F9; color: var(--text-muted); border: 2px solid transparent; border-radius: 12px; font-size: 0.85rem; font-weight: 800; cursor: pointer; transition: all 0.2s; }
.radio-chip input[type="radio"]:checked + span { background: var(--white); color: var(--primary); border-color: var(--primary); box-shadow: 0 4px 10px rgba(162,136,248,0.2); }
.fee-history-item { display: flex; justify-content: space-between; align-items: center; padding: 12px; background: #F8FAFC; border-radius: 12px; border: 1px solid #E2E8F0; }
.fee-history-item .fh-left { display: flex; flex-direction: column; gap: 4px; }
.fee-history-item .fh-date { font-size: 0.85rem; font-weight: 800; color: var(--text-dark); }
.fee-history-item .fh-meta { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.fee-history-item .fh-amount { font-size: 1.1rem; font-weight: 800; color: var(--accent-green); }

/* RESULTS & MARKS UI */
.res-row { background: var(--white); border: 1px solid var(--border-light); border-radius: 16px; padding: 12px 16px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow-sm); }
.res-input { width: 75px; padding: 8px 10px; border: 2px solid #E2E8F0; border-radius: 10px; font-size: 1.05rem; font-weight: 800; text-align: center; color: var(--primary-dark); transition: all 0.2s; }
.res-input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(162,136,248,0.15); }
.res-row.disabled { opacity: 0.7; pointer-events: none; background: #F8FAFC; }

/* COLLECT FEE LEDGER UI */
.cf-date-header { background: #F1F5F9; padding: 6px 16px; font-size: 0.85rem; font-weight: 800; color: var(--text-dark); border-bottom: 1px solid #E2E8F0; border-top: 1px solid #E2E8F0; }
.cf-date-header:first-child { border-top: none; }
.cf-item { background: var(--white); padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #E2E8F0; user-select: none; -webkit-user-select: none; }
.cf-item:last-child { border-bottom: none; }
.cf-left { display: flex; flex-direction: column; gap: 4px; }
.cf-title { font-size: 0.95rem; font-weight: 800; color: var(--text-dark); }
.cf-time { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); }
.cf-amount { font-size: 1.1rem; font-weight: 800; color: var(--accent-green); }

/* ANALYTICS UI */
.chart-container { background: var(--white); border: 1px solid var(--border-light); border-radius: 16px; padding: 16px; box-shadow: var(--shadow-sm); width: 100%; }

/* NOTIFICATION BADGE */
.notification-badge { position: absolute; top: -5px; right: 0px; background: #EF4444; color: white; font-size: 0.7rem; font-weight: 800; padding: 2px 6px; border-radius: 10px; border: 2px solid var(--app-bg); box-shadow: 0 4px 10px rgba(239,68,68,0.4); z-index: 10; }

/* BIRTHDAY LIST UI */
.bdy-card { background: var(--white); border-radius: 16px; padding: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 16px; border: 1px solid var(--border-light); box-shadow: var(--shadow-sm); }
.bdy-icon { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; background: #FFE8ED; color: #FF6B6B; flex-shrink: 0; }
.bdy-info { display: flex; flex-direction: column; flex: 1; }
.bdy-name { font-weight: 800; color: var(--text-dark); font-size: 1rem; }
.bdy-date { font-size: 0.8rem; color: var(--text-muted); font-weight: 700; }
.bdy-today { background: linear-gradient(135deg, #FF6B6B 0%, #FF8E8E 100%); color: white; border: none; box-shadow: 0 8px 20px rgba(255,107,107,0.3); }
.bdy-today .bdy-icon { background: rgba(255,255,255,0.2); color: white; }
.bdy-today .bdy-name { color: white; }
.bdy-today .bdy-date { color: rgba(255,255,255,0.9); }