@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

/* =========================================================================
   DESIGN SYSTEM & CUSTOM PROPERTIES (THEME)
   ========================================================================= */
:root {
    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    
    /* Harmonious Slate/Dark Palette */
    --bg-base: #0b0f19;
    --bg-surface: rgba(17, 24, 39, 0.7);
    --bg-surface-hover: rgba(31, 41, 55, 0.8);
    --bg-glass: rgba(17, 25, 40, 0.55);
    
    /* Brand Gradients & Accents */
    --color-primary: #6366f1; /* Indigo */
    --color-primary-glow: rgba(99, 102, 241, 0.15);
    --color-secondary: #ec4899; /* Pink */
    --color-success: #10b981; /* Emerald */
    --color-success-bg: rgba(16, 185, 129, 0.1);
    --color-error: #ef4444; /* Rose */
    --color-error-bg: rgba(239, 68, 68, 0.1);
    --color-warning: #f59e0b; /* Amber */
    --color-warning-bg: rgba(245, 158, 11, 0.1);
    
    /* Text */
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #111827;
    
    /* Layout Constants */
    --border-glass: rgba(255, 255, 255, 0.08);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================================================
   BASE RESET & LAYOUT
   ========================================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.1) 0px, transparent 50%),
        radial-gradient(at 50% 50%, rgba(15, 23, 42, 0.95) 0px, var(--bg-base) 100%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.5;
    padding-bottom: 60px;
    overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

/* =========================================================================
   NAVIGATION PORTAL
   ========================================================================= */
.app-header {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 1.3rem;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-main) 30%, var(--color-primary) 70%, var(--color-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.nav-link:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: var(--text-main);
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

/* =========================================================================
   CONTAINERS & CARDS
   ========================================================================= */
.main-container {
    max-width: 1200px;
    margin: 32px auto 0 auto;
    padding: 0 24px;
}

.glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-premium);
    padding: 32px;
    margin-bottom: 24px;
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.card-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text-main);
    border-left: 4px solid var(--color-primary);
    padding-left: 12px;
}

/* =========================================================================
   STATISTICS GRID (HEADMASTER VIEW)
   ========================================================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition-smooth);
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.3);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.primary {
    background: rgba(99, 102, 241, 0.15);
    color: var(--color-primary);
}

.stat-icon.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-success);
}

.stat-icon.warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-warning);
}

.stat-details h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-details .value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
    margin-top: 4px;
}

/* =========================================================================
   FORM CONTROLS
   ========================================================================= */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.form-select, .form-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 500;
    outline: none;
    transition: var(--transition-smooth);
}

.form-select:hover, .form-input:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
}

.form-select:focus, .form-input:focus {
    border-color: var(--color-primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 4px var(--color-primary-glow);
}

.form-select option {
    background: #0f172a;
    color: var(--text-main);
}

/* Interactive Attendance Grid */
.attendance-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.gender-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.gender-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
}

.gender-box.boys::before {
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
}

.gender-box.girls::before {
    background: linear-gradient(90deg, #ec4899, #f472b6);
}

.gender-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.gender-box.boys .gender-title { color: #60a5fa; }
.gender-box.girls .gender-title { color: #f472b6; }

.count-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
}

.count-stat {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: var(--radius-sm);
}

.count-stat .label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.count-stat .number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Number selector styling */
.number-spinner-container {
    flex: 1.2;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.spinner-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 8px 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    user-select: none;
}

.spinner-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.spinner-btn:active {
    transform: scale(0.9);
}

.spinner-input {
    width: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
    outline: none;
    -moz-appearance: textfield;
}

.spinner-input::-webkit-outer-spin-button,
.spinner-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Calculation summary section */
.calc-summary {
    background: rgba(99, 102, 241, 0.05);
    border: 1px dashed rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 24px;
}

.calc-item {
    text-align: center;
}

.calc-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    display: block;
}

.calc-val {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-main);
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    border: none;
    color: white;
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
    filter: brightness(1.1);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(1px) scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Action button for table entry */
.btn-action-enter {
    background: linear-gradient(135deg, var(--color-primary), #4f46e5);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
    transition: var(--transition-smooth);
}

.btn-action-enter:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-action-enter:active {
    transform: translateY(1px);
}

/* =========================================================================
   TABLE STYLING
   ========================================================================= */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-glass);
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

.custom-table th {
    background: rgba(17, 24, 39, 0.85);
    padding: 16px;
    font-weight: 700;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-glass);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.custom-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-glass);
    color: var(--text-main);
    transition: var(--transition-smooth);
}

.custom-table tr {
    background: transparent;
    transition: var(--transition-smooth);
}

.custom-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.custom-table tr:last-child td {
    border-bottom: none;
}

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-submitted {
    background-color: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-absent {
    background-color: var(--color-error-bg);
    color: var(--color-error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-role {
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
}

/* =========================================================================
   MODAL WINDOW (ON-BEHALF SUBMISSIONS)
   ========================================================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(3, 7, 18, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 16px;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 550px;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.modal-overlay.open .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.modal-close:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-glass);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* =========================================================================
   NOTIFICATIONS / TOAST BANNER
   ========================================================================= */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    min-width: 320px;
    max-width: 400px;
    background: var(--bg-glass);
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    box-shadow: var(--shadow-premium);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transition: var(--transition-smooth);
    border-top: 1px solid var(--border-glass);
    border-right: 1px solid var(--border-glass);
    border-bottom: 1px solid var(--border-glass);
    backdrop-filter: blur(12px);
}

.toast.toast-success {
    border-left-color: var(--color-success);
}

.toast.toast-error {
    border-left-color: var(--color-error);
}

.toast.toast-info {
    border-left-color: var(--color-primary);
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.toast-msg {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.toast-close:hover {
    color: var(--text-main);
}

/* =========================================================================
   ANIMATIONS & LOADING INDICATORS
   ========================================================================= */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(100px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

.global-loader-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.global-loader {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(99, 102, 241, 0.1);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* No data styling */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

/* =========================================================================
   RESPONSIVE DESIGN SYSTEM (MOBILE COMPATIBILITY)
   ========================================================================= */
@media (max-width: 768px) {
    body {
        padding-bottom: 80px;
    }
    
    .nav-container {
        flex-direction: column;
        gap: 16px;
        padding: 12px;
    }
    
    .main-container {
        margin-top: 16px;
        padding: 0 12px;
    }
    
    .glass-card {
        padding: 16px;
    }
    
    .attendance-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .calc-summary {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
        padding: 12px;
    }
    
    .custom-table th, .custom-table td {
        padding: 12px 8px;
        font-size: 0.85rem;
    }
    
    .badge {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
    
    .btn-secondary {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    .btn-action-enter {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
}

/* =========================================================================
   LOGIN HELPER STYLING RULES
   ========================================================================= */
details summary {
    transition: var(--transition-smooth);
}
details summary:hover {
    color: var(--text-main) !important;
}
details[open] summary {
    border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
    padding-bottom: 8px;
    margin-bottom: 8px;
}

