/* Main Styles */
:root {
    --primary: #2563EB;
    --primary-dark: #1E40AF;
    --accent: #F59E0B;
    --danger: #EF4444;
    --success: #10B981;
    --bg-body: #F3F4F6;
    --bg-white: #FFFFFF;
    --text-main: #111827;
    --text-muted: #6B7280;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

body.dark-mode {
    --bg-body: #111827;
    --bg-white: #1F2937;
    --text-main: #F9FAFB;
    --text-muted: #9CA3AF;
    --bg-card: #1F2937;
    /* If used */
    /* Ensure borders are subtle in dark mode */
}

/* Fix border colors in dark mode via specific rules or variable if border used var? */
/* Current borders use #E5E7EB. We should var-ify it or override globally. */
/* For now, let's keep it simple. */
body.dark-mode .mobile-header,
body.dark-mode .sidebar,
body.dark-mode .card,
body.dark-mode .form-input {
    border-color: #374151;
    /* Darker border */
    border-color: #374151;
    /* Darker border */
}

/* Login Dark Mode Fixes */
body.dark-mode .form-input {
    background: #374151;
    border-color: #4B5563;
    color: var(--text-main);
}

body.dark-mode .form-input:focus {
    background: #1F2937;
    border-color: var(--primary);
}

body.dark-mode .tabs {
    background: #374151;
}

body.dark-mode .tab.active {
    background: #1F2937;
    color: var(--primary);
}

body.dark-mode .error-box {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #FCA5A5 !important;
}

/* Theme Toggle Button for Login Page */
.theme-toggle-login {
    position: absolute;
    top: 20px;
    left: 20px;
    /* RTL means Left is far side? No, Left is left. */
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.theme-toggle-login:hover {
    background: rgba(0, 0, 0, 0.05);
}

body.dark-mode .theme-toggle-login:hover {
    background: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-body);
    /* Subtle background gradient to show off glass effect */
    background-image:
        radial-gradient(circle at 10% 20%, rgba(37, 99, 235, 0.05) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(245, 158, 11, 0.05) 0%, transparent 20%),
        radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.03) 0%, transparent 30%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

body.dark-mode {
    background-image:
        radial-gradient(circle at 10% 20%, rgba(37, 99, 235, 0.1) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(245, 158, 11, 0.1) 0%, transparent 20%);
}

/* Utilities */
.hidden {
    display: none !important;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.fade-in-up {
    animation: fadeInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    /* Modern easing */
}

.flex-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.text-primary {
    color: var(--primary);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    /* Always white text on primary button */
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-logout {
    background: #FEF2F2;
    color: var(--danger);
}

/* Login */
#login-view {
    display: flex;
    min-height: 100vh;
    background: var(--bg-white);
}

body.dark-mode #login-view {
    background: var(--bg-body);
}

body.dark-mode .login-right {
    background: linear-gradient(135deg, #1e3a8a, #172554);
    /* Darker blue gradient */
}

.login-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px;
    max-width: 600px;
    margin: 0 auto;
}

.login-right {
    flex: 1;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    padding: 40px;
}

.login-brand {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

body.dark-mode .login-brand {
    color: white;
    /* Or keep primary if it pops well, but white is safer on dark bg */
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-main);
}

.form-input {
    width: 100%;
    padding: 14px;
    border: 2px solid #E5E7EB;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color 0.2s;
    background: #F9FAFB;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-white);
}

/* Modern Select */
.styled-select {
    width: 100%;
    padding: 10px 16px;
    padding-left: 40px;
    /* Space for arrow in RTL */
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    /* Smoother radius */
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: var(--bg-white);
    appearance: none;
    /* Remove default arrow */
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3e%3cpath fill='none' d='M0 0h24v24H0z'/%3e%3cpath d='M12 13.172l4.95-4.95 1.414 1.414L12 16 5.636 9.636 7.05 8.222z' fill='%236B7280'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 12px center;
    /* RTL: Arrow on left */
    background-size: 20px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.styled-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.styled-select:hover {
    border-color: #D1D5DB;
    background-color: #F9FAFB;
}

body.dark-mode .styled-select {
    background-color: #374151;
    border-color: #4B5563;
    color: var(--text-main);
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3e%3cpath fill='none' d='M0 0h24v24H0z'/%3e%3cpath d='M12 13.172l4.95-4.95 1.414 1.414L12 16 5.636 9.636 7.05 8.222z' fill='%239CA3AF'/%3e%3c/svg%3e");
}

body.dark-mode .styled-select:focus {
    border-color: var(--primary);
    background-color: #1F2937;
}

/* Custom JS Dropdown Styles */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    width: 100%;
    flex: 1;
    font-size: 0.95rem;
}

.custom-select-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-white);
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
}

.custom-select-trigger:hover {
    border-color: #D1D5DB;
    background-color: #F9FAFB;
}

.custom-select-trigger::after {
    content: '';
    width: 6px;
    height: 6px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg);
    transition: 0.2s;
    margin-right: 10px;
    /* RTL fix */
}

/* RTL Chevron */
[dir="rtl"] .custom-select-trigger::after {
    margin-right: 0;
    margin-left: 0;
}

.custom-options {
    position: absolute;
    top: 110%;
    left: 0;
    right: 0;
    background: var(--bg-white);
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 250px;
    overflow-y: auto;
}

.custom-select-wrapper.open .custom-options {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transform: translateY(0);
}

.custom-select-wrapper.open .custom-select-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.custom-select-wrapper.open .custom-select-trigger::after {
    transform: rotate(225deg);
    border-color: var(--primary);
}

.custom-option {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #F9FAFB;
    color: var(--text-main);
}

.custom-option:last-child {
    border-bottom: none;
}

.custom-option:hover {
    background-color: #F3F4F6;
    color: var(--primary);
}

.custom-option.selected {
    background-color: rgba(88, 65, 227, 0.1);
    /* Primary with opacity */
    color: var(--primary);
    font-weight: 700;
}

body.dark-mode .custom-select-trigger,
body.dark-mode .custom-options {
    background: #374151;
    border-color: #4B5563;
    color: var(--text-main);
}

body.dark-mode .custom-option {
    border-bottom-color: #4B5563;
    color: var(--text-main);
}

body.dark-mode .custom-option:hover {
    background-color: #4B5563;
}

body.dark-mode .custom-option.selected {
    background-color: rgba(88, 65, 227, 0.2);
    color: var(--primary);
}

.tabs {
    display: flex;
    background: #F3F4F6;
    padding: 4px;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
}

.tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    border-radius: 6px;
    color: var(--text-muted);
    font-weight: 600;
    border: none;
    background: transparent;
    transition: 0.2s;
}

.tab.active {
    background: var(--bg-white);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

@media (max-width: 900px) {
    .login-right {
        display: none;
    }
}

/* Layout */
/* Glassmorphism Mobile Header */
/* Layout Architecture: CSS Grid Dashboard */
.app-container {
    display: flex;
    height: 100vh;
    /* Lock to viewport height */
    overflow: hidden;
    /* Prevent body scroll */
    width: 100%;
}

/* Sidebar Column */
.sidebar {
    width: 280px;
    height: 100%;
    /* Full height of container */
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-left: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    z-index: 50;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

body.dark-mode .sidebar {
    background: rgba(31, 41, 55, 0.85);
    border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid #F3F4F6;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.nav-menu {
    flex: 1;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    text-decoration: none;
}

.nav-icon-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.mobile-nav-icon-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    margin-bottom: 2px;
}

.nav-item:hover,
.nav-item.active {
    background: #EFF6FF;
    color: var(--primary);
}

.user-profile {
    padding: 20px;
    border-top: 1px solid #F3F4F6;
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: #E0E7FF;
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* Main Content Column (Wrapper) */
.main-wrapper {
    flex: 1;
    display: grid;
    grid-template-rows: auto 1fr;
    /* Row 1: Header (Auto), Row 2: Content (Flex) */
    height: 100%;
    overflow: hidden;
    position: relative;
    min-width: 0;
}

/* Header inside Main Wrapper */
.mobile-header {
    display: flex;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 16px 32px;
    z-index: 40;
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);
    justify-content: space-between;
    align-items: center;
    width: 100%;
    /* No sticky needed in grid layout, it sits in row 1 */
}

body.dark-mode .mobile-header {
    background: rgba(31, 41, 55, 0.85);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Main Content Area - Scrollable */
.main-content {
    width: 100%;
    padding: 20px 32px;
    overflow-y: auto;
    /* Internal Scroll */
    height: 100%;
    /* Fill Row 2 */
}

/* Custom Scrollbar for Main Content */
.main-content::-webkit-scrollbar {
    width: 6px;
}

.main-content::-webkit-scrollbar-track {
    background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

body.dark-mode .main-content::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Responsive: Tablet/Mobile */
@media (max-width: 1024px) {
    .app-container {
        display: block;
        /* Fallback to standard flow on mobile */
        height: auto;
        overflow: visible;
    }

    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        height: 100vh;
        width: 280px;
        transform: translateX(100%);
        z-index: 1000;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-wrapper {
        display: block;
        /* Back to block flow */
        height: auto;
        border: none;
    }

    .mobile-header {
        position: sticky;
        /* Sticky is good for mobile */
        top: 0;
        padding: 16px 20px;
    }

    .main-content {
        overflow-y: visible;
        /* Let body scroll */
        height: auto;
        padding: 20px 16px 80px 16px;
    }

    /* Reduce padding for schedule page */
    #schedule__view {
        padding-top: 0;
        margin-top: -12px;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
    }

    .screen-title {
        display: none !important;
    }
}

.screen-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 24px;
    color: var(--text-main);
}

.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-white);
    border-top: 1px solid #E5E7EB;
    z-index: 100;
    justify-content: space-around;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
}

.mobile-nav-item.active {
    color: var(--primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.icon-btn:hover {
    background: #F3F4F6;
    color: var(--primary);
}

body.dark-mode .icon-btn:hover {
    background: #374151;
}

.notif-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 10px;
    height: 10px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-white);
    display: none;
}

.notif-badge.active {
    display: block;
}

.header-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: opacity 0.2s;
}

/* .header-profile:hover {
    opacity: 0.8;
} Removed to prevent dropdown transparency */

.header-avatar-circle {
    width: 38px;
    height: 38px;
    background: #E0E7FF;
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    border: 2px solid #FFFFFF;
    box-shadow: 0 0 0 1px #E5E7EB;
}

.header-info {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Profile Dropdown */
.profile-dropdown {
    position: absolute;
    top: 55px;
    left: 0;
    width: 240px;
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 0;
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.profile-dropdown.show {
    display: flex;
    animation: fadeIn 0.1s ease-out;
}

.dropdown-header-info {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #F9FAFB;
    border-bottom: 1px solid #E5E7EB;
}

.dropdown-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1rem;
}

.dropdown-user-details h4 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 700;
}

.dropdown-user-details span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-main);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9rem;
    border-bottom: 1px solid #F3F4F6;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: #F3F4F6;
}

.dropdown-item i {
    font-size: 1.1rem;
    color: var(--text-muted);
}

.dropdown-item:hover i {
    color: var(--primary);
}

/* Specific for logout */
.dropdown-item.logout-item {
    color: var(--danger);
}

.dropdown-item.logout-item:hover {
    background: #FEF2F2;
}

.dropdown-item.logout-item i {
    color: var(--danger);
}

body.dark-mode .profile-dropdown {
    background: var(--bg-card);
    border-color: #374151;
}

body.dark-mode .dropdown-header-info {
    background: #374151;
    border-color: #4B5563;
}

body.dark-mode .dropdown-item {
    border-color: #374151;
}

body.dark-mode .dropdown-item:hover {
    background: #374151;
}

/* Modern Popover Attendance */
/* Modern Popover Attendance */
.attendance-popover {
    position: fixed;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 20px;
    padding: 24px;
    width: 280px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.02);
    z-index: 3000;
    display: none;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: popoverFadeIn 0.2s ease-out forwards;
}

.attendance-popover.visible {
    display: flex;
}

body.dark-mode .attendance-popover {
    background: #1F2937;
    border-color: rgba(255, 255, 255, 0.1);
    color: white;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

@keyframes popoverFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.popover-icon-circle {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: 50%;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    box-shadow: 0 8px 20px rgba(var(--primary-rgb), 0.25);
}

/* Arrow (Desktop Only) */
.attendance-popover::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 16px;
    height: 16px;
    background: inherit;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    /* Match popover border */
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 0;
}

body.dark-mode .attendance-popover::after {
    border-color: rgba(255, 255, 255, 0.1);
}

/* Mobile Responsive: Bottom Sheet */
@media (max-width: 768px) {
    .attendance-popover {
        position: fixed;
        /* Center Popover */
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        margin: auto !important;
        width: 85%;
        max-width: 320px;
        height: fit-content;

        border-radius: 20px;
        /* Use Fade In like desktop */
        animation: popoverFadeIn 0.25s ease-out forwards;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
        padding-bottom: 24px;
    }

    .attendance-popover::after {
        display: none;
        /* Hide arrow on mobile */
    }

    /* Remove bottom sheet handle */
    .attendance-popover::before {
        display: none;
    }
}



body.dark-mode .attendance-popover::after {
    border-color: rgba(255, 255, 255, 0.1);
}

/* Close btn unnecessary for hover/click-outside popover usually, but keeping small X */
.popover-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.2rem;
}

/* Fix for profile-dropdown in dark mode (Ensure items are visible) */
body.dark-mode .dropdown-item {
    color: var(--text-main);
}

body.dark-mode .dropdown-item:hover {
    background: #4B5563;
}

.screen-title {
    display: none;
}

@media (max-width: 1024px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-right: 0;
        padding: 20px;
        padding-bottom: 80px;
        padding-top: 20px;
    }

    /* Pro Mobile Navigation - Clean & Sleek */
    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #FFFFFF;
        /* Solid white for cleanliness, or very subtle blur */
        border-top: 1px solid #F3F4F6;
        padding: 0 12px;
        box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.04);
        /* Very subtle shadow */
        justify-content: space-between;
        /* Better spacing */
        align-items: center;
        z-index: 1000;
        height: 65px;
        /* Compact height */
        padding-bottom: env(safe-area-inset-bottom, 0);
        /* Safety for iPhone X+ */
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        color: #9CA3AF;
        /* Weaker gray for inactive */
        font-size: 0.65rem;
        cursor: pointer;
        padding: 4px 0;
        border-radius: 8px;
        font-weight: 500;
        flex: 1;
        height: 100%;
        transition: color 0.2s ease;
        position: relative;
    }

    .mobile-nav-item i {
        font-size: 1.5rem;
        margin-bottom: 2px;
        transition: color 0.2s ease;
    }

    .mobile-nav-item span {
        font-weight: 600;
        letter-spacing: 0.01em;
    }

    /* Active State - Simple & Professional */
    .mobile-nav-item.active {
        color: var(--primary);
    }

    /* Center Floating Button - Pro FAB Style */
    .mobile-nav-item.nav-center-btn {
        background: var(--primary);
        color: white;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        bottom: 24px;
        /* Float amount */
        box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
        /* Clean shadow */
        border: 4px solid #F3F4F6;
        /* Matches body bg usually, slightly grey */
        flex: none;
        margin: 0 8px;
        /* Spacing from neighbors */
        transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }

    .mobile-nav-item.nav-center-btn i {
        font-size: 1.6rem;
        margin: 0;
    }

    .mobile-nav-item.nav-center-btn:active {
        transform: scale(0.95);
    }

    .mobile-nav-item.nav-center-btn.active {
        box-shadow: 0 6px 16px rgba(37, 99, 235, 0.45);
        background: var(--primary);
    }

    /* Dark Mode Polish */
    body.dark-mode .mobile-nav {
        background: #1F2937;
        border-top: 1px solid #374151;
        box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.2);
    }

    body.dark-mode .mobile-nav-item {
        color: #E5E7EB;
    }

    body.dark-mode .mobile-nav-item.active {
        color: #60A5FA;
    }

    body.dark-mode .mobile-nav-item.nav-center-btn {
        border-color: #FFFFFF;
        box-shadow: 0 0 20px rgba(37, 99, 235, 0.5);
        /* Blue glow */
    }

    body.dark-mode .mobile-nav-item.nav-center-btn.active {
        border-color: #FFFFFF;
        color: #FFFFFF;
        box-shadow: 0 0 25px rgba(255, 255, 255, 0.3);
        /* White/Blue stronger glow */
    }

    .mobile-header {
        right: 0;
    }

    .header-info {
        display: none;
    }

    /* Hide Page Title Text in Mobile */
    #mobilePageTitle {
        display: none;
    }

    /* Keep the icon visible, or hide that too if desired. Usually icon is fine as indicator */

    /* Improve Notification Dropdown on Mobile */
    .notif-dropdown {
        position: fixed;
        top: 70px;
        left: 50%;
        transform: translateX(-50%);
        width: 90%;
        max-width: 380px;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    }
}

/* Cards & Grid */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

/* Glassmorphism Cards */
.card {
    background: rgba(255, 255, 255, 0.7);
    /* More transparent */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-md);
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
    /* Soft deep shadow */
}

body.dark-mode .card {
    background: rgba(31, 41, 55, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.info-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.info-avatar-lg {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--primary), #60A5FA);
    color: white;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.data-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px dashed #E5E7EB;
}

.data-row:last-child {
    border: none;
}

.data-label {
    color: var(--text-muted);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.data-value {
    font-weight: 600;
    color: var(--text-main);
}

/* Components */
.notif-card {
    background: #EFF6FF;
    border-left: 4px solid var(--primary);
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 8px;
    display: flex;
    align-items: start;
    gap: 12px;
}

.notif-icon {
    color: var(--primary);
    font-size: 1.2rem;
    margin-top: 2px;
}

.enroll-card {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    border: 1px solid #E5E7EB;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.enroll-header {
    background: #F9FAFB;
    padding: 16px;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.group-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-dark);
}

.enroll-body {
    padding: 16px;
}

.data-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 6px 0;
    font-size: 0.95rem;
}

.data-label {
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.data-value {
    color: var(--text-main);
    font-weight: 700;
    text-align: left;
    direction: ltr;
    /* Force times to look correct */
    max-width: 65%;
    white-space: pre-wrap;
    /* Preserve newlines if any */
}

.status-badge {
    background: #D1FAE5;
    color: #065F46;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
}

.child-switcher {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 24px;
}

.child-pill {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #E5E7EB;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    transition: background 0.3s, box-shadow 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Sliding Shine Effect for Child Pill */
.child-pill::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(120deg,
            transparent,
            rgba(255, 255, 255, 0.6),
            transparent);
    transition: all 0.6s;
    transform: skewX(-25deg);
    pointer-events: none;
}

.child-pill:hover::before,
.child-pill:active::before {
    left: 100%;
    transition: 0.7s;
}

.child-pill:hover,
.child-pill:active {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    background: #FFFFFF;
}

.child-pill.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.child-pill.active:hover {
    background: var(--primary-dark);
}

/* Calendar */
.calendar-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Mobile Tabs */
.mobile-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px;
    padding-bottom: 8px;
    margin-bottom: 8px;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE */
}

.mobile-tabs::-webkit-scrollbar {
    display: none;
}

.mobile-tab {
    padding: 8px 16px;
    border-radius: 50px;
    background: white;
    border: 1px solid #E5E7EB;
    white-space: nowrap;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s;
    font-size: 0.9rem;
}

.mobile-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Dark Mode Active Tab Fix */
body.dark-mode .mobile-tab.active {
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary) !important;
}

/* ========== WEEKLY TIMETABLE - MODERN DESIGN ========== */
.calendar-wrapper {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.calendar-day {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.calendar-day:hover {
    transform: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.day-header {
    background: linear-gradient(135deg, #F3F4F6 0%, #E5E7EB 100%);
    padding: 14px 12px;
    font-weight: 800;
    text-align: center;
    border-bottom: 1px solid #E5E7EB;
    color: var(--text-main);
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

.day-header.today {
    background: linear-gradient(135deg, var(--primary) 0%, #1E40AF 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

.day-body {
    padding: 12px;
    height: auto;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: transparent;
    flex: 1;
}

/* Event Cards - Consistent Design */
.event-card {
    background: var(--bg-white);
    border: 1px solid rgba(37, 99, 235, 0.15);
    border-right: 4px solid var(--primary);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.08);
    position: relative;
    cursor: default;
}

.event-card::before {
    display: none;
}

.event-card:hover {
    transform: none;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.08);
}

.event-time {
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    background: transparent;
    padding: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-main);
    line-height: 1.3;
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.event-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

.event-room,
.event-teacher {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

/* Event Icons */
.event-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-left: 2px;
}

.tag {
    background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
    color: var(--primary);
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.75rem;
    border: 1px solid rgba(37, 99, 235, 0.1);
}

/* Dark Mode Timetable */
body.dark-mode .calendar-day {
    background: rgba(31, 41, 55, 0.8);
    border-color: #374151;
}

body.dark-mode .day-header {
    background: linear-gradient(135deg, #374151 0%, #1F2937 100%);
    border-color: #4B5563;
    color: white;
}

body.dark-mode .day-header.today {
    background: linear-gradient(135deg, var(--primary) 0%, #1E40AF 100%);
}

body.dark-mode .day-body {
    background: linear-gradient(180deg, #1F2937 0%, #111827 100%);
}

/* Desktop dark mode event card styles - handled separately in mobile media query */

body.dark-mode .tag {
    background: rgba(37, 99, 235, 0.15);
    border-color: rgba(37, 99, 235, 0.3);
}

/* ========== WEEK ROW - Base Styles (All Screens) ========== */
.week-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0;
    padding: 0;
    margin-bottom: 16px;
    background: transparent;
}

.week-day {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 12px 4px 18px 4px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    position: relative;
}

.week-day .day-num {
    font-size: 1.2rem;
    font-weight: 700;
    color: #374151;
}

.week-day .day-name {
    font-size: 0.7rem;
    color: #9CA3AF;
    font-weight: 500;
    text-transform: uppercase;
}

/* Active (selected) day - Blue background */
.week-day.active {
    background: #EFF6FF;
}

.week-day.active .day-num,
.week-day.active .day-name {
    color: var(--primary);
}

/* Today - Always has dot indicator */
.week-day .day-dot {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
}

/* Full day name - hidden on mobile, shown on desktop */
.week-day .day-name-full {
    display: none;
}

/* Dark Mode Week Row */
body.dark-mode .week-day .day-num {
    color: #E5E7EB;
}

body.dark-mode .week-day .day-name {
    color: #6B7280;
}

body.dark-mode .week-day.active {
    background: rgba(37, 99, 235, 0.15);
}

body.dark-mode .week-day.active .day-num,
body.dark-mode .week-day.active .day-name {
    color: #60A5FA;
}

body.dark-mode .week-day .day-dot {
    background: #60A5FA;
}

@media (max-width: 1024px) {

    /* ========== MOBILE TIMETABLE - TIMELINE DESIGN ========== */
    /* Mobile-specific: pull week-row closer to header */
    .week-row {
        margin-top: -8px;
    }

    .calendar-wrapper {
        display: block;
    }

    /* Hide schedule page title on mobile */
    #schedule__view .screen-title {
        display: none;
    }

    /* Mobile Day Tabs - Horizontal Selector */
    .mobile-tabs {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0;
        padding: 16px 0;
        margin-bottom: 24px;
        background: transparent;
    }

    .mobile-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 12px 8px 16px 8px;
        border-radius: 20px;
        cursor: pointer;
        transition: all 0.2s ease;
        background: transparent;
        border: none;
        position: relative;
    }

    .mobile-tab .day-num {
        font-size: 1.3rem;
        font-weight: 700;
        color: #374151;
    }

    .mobile-tab .day-name {
        font-size: 0.75rem;
        color: #9CA3AF;
        font-weight: 500;
    }

    .mobile-tab.active {
        background: #FEE2E2;
    }

    .mobile-tab.active .day-num {
        color: #E11D48;
    }

    .mobile-tab.active .day-name {
        color: #E11D48;
    }

    .mobile-tab.active::after {
        content: '';
        position: absolute;
        bottom: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 6px;
        height: 6px;
        background: #E11D48;
        border-radius: 50%;
    }

    /* Today indicator - always shows dot */
    .mobile-tab.today::after {
        content: '';
        position: absolute;
        bottom: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 6px;
        height: 6px;
        background: #E11D48;
        border-radius: 50%;
    }

    /* Dark Mode Day Tabs */
    body.dark-mode .mobile-tab .day-num {
        color: #E5E7EB;
    }

    body.dark-mode .mobile-tab .day-name {
        color: #6B7280;
    }

    body.dark-mode .mobile-tab.active {
        background: rgba(225, 29, 72, 0.15);
    }

    body.dark-mode .mobile-tab.active .day-num,
    body.dark-mode .mobile-tab.active .day-name {
        color: #F87171;
    }

    body.dark-mode .mobile-tab.active::after,
    body.dark-mode .mobile-tab.today::after {
        background: #F87171;
    }

    /* Calendar Day Container */
    .calendar-day {
        display: none;
        margin-top: 0;
        min-height: auto;
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }

    .calendar-day:hover {
        transform: none;
        box-shadow: none;
    }

    .calendar-day.active-mobile {
        display: block;
        animation: fadeIn 0.3s forwards;
    }

    .day-header {
        display: none;
        /* Hidden - using mobile-tabs instead */
    }

    .day-body {
        background: transparent;
        padding: 0;
        min-height: auto;
        gap: 16px;
    }

    /* Timeline Event Cards - Mobile - Blue Theme */
    .event-card {
        background: var(--bg-white);
        border: 1px solid rgba(37, 99, 235, 0.15);
        border-right: 4px solid var(--primary);
        border-radius: 12px;
        padding: 12px;
        box-shadow: 0 2px 10px rgba(37, 99, 235, 0.08);
        position: relative !important;
        margin-right: 0;
        cursor: default;
        top: auto !important;
        height: auto !important;
        left: auto !important;
        width: 100% !important;
    }

    .event-card::before {
        display: none;
    }

    .event-card:hover {
        transform: none;
        box-shadow: 0 2px 10px rgba(37, 99, 235, 0.08);
    }

    .event-time {
        background: transparent;
        color: var(--primary);
        font-size: 0.8rem;
        font-weight: 700;
        padding: 0;
        display: inline-flex;
        align-items: center;
        gap: 4px;
    }

    .event-icon {
        width: 16px;
        height: 16px;
        vertical-align: middle;
        margin-left: 2px;
    }

    .event-title {
        color: var(--text-main);
        font-size: 0.95rem;
        font-weight: 700;
        margin-top: 4px;
    }

    .event-sub {
        color: var(--text-muted);
        margin-top: 4px;
        gap: 12px;
    }

    .event-room {
        margin-left: 8px;
    }

    .tag {
        background: #EFF6FF;
        color: var(--primary);
        border: 1px solid rgba(37, 99, 235, 0.15);
        padding: 2px 8px;
        font-weight: 600;
        font-size: 0.75rem;
    }

    /* Dark Mode Mobile Event Cards */
    body.dark-mode .event-card {
        background: var(--bg-card);
        border-color: #374151;
        border-right-color: var(--primary);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
        cursor: default;
    }

    body.dark-mode .event-card:hover {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    }

    body.dark-mode .event-time {
        background: transparent;
        color: #60A5FA;
    }

    body.dark-mode .tag {
        background: rgba(37, 99, 235, 0.15);
        border-color: rgba(37, 99, 235, 0.3);
    }

    body.dark-mode .day-body {
        background: transparent;
    }

    body.dark-mode .calendar-day {
        background: transparent;
        border: none;
        box-shadow: none;
    }
}

@media (min-width: 1024px) {

    /* Desktop */

    .mobile-tabs,
    .today-indicator {
        display: none;
    }

    /* Calendar wrapper is 7-column grid */
    .calendar-wrapper {
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 16px;
        padding: 8px;
    }

    /* Week-row spans all 7 columns and is itself a 7-col grid */
    .week-row {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: repeat(7, 1fr);
        gap: 16px;
        margin-bottom: 8px;
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(248, 250, 252, 0.95) 100%);
        border-radius: 20px;
        padding: 12px;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
        border: 1px solid rgba(255, 255, 255, 0.8);
    }

    body.dark-mode .week-row {
        background: linear-gradient(135deg, rgba(31, 41, 55, 0.9) 0%, rgba(17, 24, 39, 0.95) 100%);
        border-color: rgba(55, 65, 81, 0.5);
    }

    .week-day {
        flex: none;
        padding: 16px 8px 16px 8px;
        cursor: default;
        pointer-events: none;
        border-radius: 12px;
        transition: all 0.2s ease;
    }

    /* On desktop, only highlight today (not active) */
    .week-day.active {
        background: transparent;
    }

    .week-day.active .day-num,
    .week-day.active .day-name {
        color: inherit;
    }

    .week-day.today {
        background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
        box-shadow: inset 0 0 0 2px var(--primary);
    }

    .week-day.today .day-num,
    .week-day.today .day-name {
        color: var(--primary);
    }

    body.dark-mode .week-day.active {
        background: transparent;
    }

    body.dark-mode .week-day.today {
        background: linear-gradient(135deg, rgba(37, 99, 235, 0.2) 0%, rgba(37, 99, 235, 0.1) 100%);
        box-shadow: inset 0 0 0 2px rgba(96, 165, 250, 0.5);
    }

    body.dark-mode .week-day.today .day-num,
    body.dark-mode .week-day.today .day-name-full {
        color: #60A5FA;
    }

    /* Show full Arabic day names on desktop, hide short names */
    .week-day .day-name {
        display: none;
    }

    .week-day .day-name-full {
        display: block;
        font-size: 0.9rem;
        font-weight: 700;
        color: var(--text-muted);
        margin-top: 4px;
    }

    .week-day .day-num {
        font-size: 1.3rem;
        font-weight: 800;
    }

    .week-day.today .day-name-full {
        color: var(--primary);
    }

    body.dark-mode .week-day .day-name-full {
        color: #9CA3AF;
    }

    /* Show all calendar days on desktop - no visible container */
    .calendar-day {
        display: flex !important;
        flex-direction: column;
        background: transparent;
        border: none;
        border-radius: 0;
        box-shadow: none;
        overflow: visible;
    }

    .calendar-day:hover {
        transform: none;
        box-shadow: none;
    }

    body.dark-mode .calendar-day {
        background: transparent;
        border: none;
    }

    body.dark-mode .calendar-day:hover {
        box-shadow: none;
    }

    /* Hide old day header on desktop - using week-row instead */
    .day-header {
        display: none;
    }

    .day-body {
        height: auto;
        position: relative;
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 0;
        background: transparent;
    }

    /* Enhanced Event Cards for Desktop */
    .event-card {
        background: linear-gradient(135deg, #FFFFFF 0%, #F8FAFC 100%);
        border: 1px solid rgba(37, 99, 235, 0.12);
        border-right: 4px solid var(--primary);
        border-radius: 14px;
        padding: 14px;
        box-shadow: 0 4px 16px rgba(37, 99, 235, 0.08);
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .event-card:hover {
        transform: translateX(-4px);
        box-shadow: 0 6px 20px rgba(37, 99, 235, 0.15);
        border-color: rgba(37, 99, 235, 0.25);
    }

    body.dark-mode .event-card {
        background: linear-gradient(135deg, rgba(55, 65, 81, 0.8) 0%, rgba(31, 41, 55, 0.9) 100%);
        border-color: rgba(96, 165, 250, 0.2);
    }

    body.dark-mode .event-card:hover {
        box-shadow: 0 6px 20px rgba(96, 165, 250, 0.2);
        border-color: rgba(96, 165, 250, 0.4);
    }

    /* Header Adjustments for Desktop */
    .mobile-header {
        justify-content: space-between;
        gap: 24px;
    }

    .header-profile {
        order: 2;
        border-right: 1px solid #E5E7EB;
        padding-right: 24px;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dashboard Widgets */
.welcome-banner {
    background: #5841E3;
    color: white;
    padding: 32px;
    border-radius: var(--radius-md);
    margin-bottom: 32px;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.2);
    position: relative;
    overflow: hidden;
}

.welcome-banner h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    font-weight: 800;
}

.welcome-banner p {
    opacity: 0.9;
    font-size: 1.1rem;
    max-width: 600px;
}

.welcome-banner::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 70%);
    border-radius: 50%;
    pointer-events: none;
}

/* Welcome Banner Flex Layout */
.welcome-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 24px;
}

.welcome-content {
    flex: 1;
    min-width: 0;
}

.icon-btn-glass {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s;
}

.icon-btn-glass:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.3);
}

.welcome-qr-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(31, 41, 55, 0.95);
    /* Dark overlay */
    backdrop-filter: blur(8px);
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    animation: fadeIn 0.2s ease-out;
}

.welcome-qr-overlay.hidden {
    display: none !important;
}

.qr-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: scale(0.9);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    to {
        transform: scale(1);
    }
}

.close-qr-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    z-index: 21;
}

.qr-code-box {
    background: white;
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 180px !important;
    height: 180px !important;
}

#globalQrOverlay .qr-label {
    font-size: 1.2rem;
    margin-top: 12px;
    font-weight: 700;
}

/* Make QR code images responsive */
.qr-code-box img,
.qr-code-box canvas {
    display: block;
    border-radius: 4px;
    width: 100% !important;
    height: 100% !important;
}

.welcome-book-img {
    height: 160px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 0 25px rgba(255, 255, 255, 0.5));
    z-index: 1;
}

@media (max-width: 768px) {
    .welcome-book-img {
        height: 100px;
        margin-bottom: 0;
    }
}

.qr-label {
    font-size: 0.85rem;
    opacity: 0.9;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

/* Disable hover for static cards */
.stat-card.no-hover:hover {
    transform: none !important;
    box-shadow: var(--shadow-sm) !important;
}

body.dark-mode .stat-card {
    background: #1F2937;
    border-color: #374151;
}

/* Large Desktop (1400px+) */
@media (min-width: 1400px) {
    .qr-code-box {
        width: 120px;
        height: 120px;
        padding: 12px;
    }

    .qr-label {
        font-size: 0.9rem;
    }
}

/* Desktop (1024px - 1399px) */
@media (min-width: 1024px) and (max-width: 1399px) {
    .qr-code-box {
        width: 100px;
        height: 100px;
        padding: 10px;
    }
}

/* Tablet (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .welcome-banner {
        gap: 20px;
    }

    .qr-code-box {
        width: 90px;
        height: 90px;
        padding: 8px;
    }

    .qr-label {
        font-size: 0.75rem;
    }
}

/* Small Tablet / Large Mobile (481px - 767px) */
@media (min-width: 481px) and (max-width: 767px) {
    .welcome-banner {
        gap: 16px;
    }

    .qr-code-box {
        width: 80px;
        height: 80px;
        padding: 6px;
    }

    .qr-label {
        font-size: 0.7rem;
    }

    .welcome-banner h1 {
        font-size: 1.5rem;
    }

    .welcome-banner p {
        font-size: 0.95rem;
    }
}

/* Mobile (480px and below) */
@media (max-width: 480px) {
    .welcome-banner {
        flex-direction: row;
        flex-wrap: wrap;
        text-align: right;
        gap: 12px;
        padding: 20px;
        align-items: center;
    }

    .welcome-content {
        order: 2;
        /* Text next to image */
        flex: 1;
        min-width: 140px;
    }

    .welcome-book-img {
        order: 1;
        height: 70px !important;
        /* Force smaller size */
        margin: 0;
    }

    .welcome-qr-container {
        order: 3;
        /* Move to bottom */
        width: 100%;
        flex-direction: row;
        justify-content: center;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid rgba(255, 255, 255, 0.2);
    }

    .qr-code-box {
        width: 75px;
        height: 75px;
        padding: 5px;
    }

    .qr-label {
        font-size: 0.75rem;
    }

    .welcome-banner h1 {
        font-size: clamp(0.9rem, 5vw, 1.4rem);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.2;
    }

    .welcome-banner p {
        font-size: clamp(0.7rem, 3.5vw, 0.9rem);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 0;
    }

    /* Tighten Header Icons */
    .header-actions {
        gap: 6px !important;
    }

    .header-controls {
        gap: 8px !important;
    }

    .mobile-header {
        padding: 12px 16px;
    }
}

.stats-grid {
    display: grid;
    /* On mobile/tablet, wrap as usual */
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

@media (min-width: 1024px) {
    .stats-grid {
        /* Force 3 columns on Desktop */
        grid-template-columns: 1fr 1fr 1fr;
    }
}

/* Prevent text wrapping inside cards */
.stat-label,
.stat-value {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 640px) {
    .stats-grid {
        gap: 16px;
        margin-bottom: 24px;
    }
}

.stat-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
    position: relative;
}

/* Sliding Shine Effect */
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(120deg,
            transparent,
            rgba(255, 255, 255, 0.6),
            transparent);
    transition: all 0.6s;
    transform: skewX(-25deg);
    pointer-events: none;
}

.stat-card:hover::before {
    left: 100%;
    transition: 0.7s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    /* Stronger shadow on hover */
}

.stat-icon {
    width: 48px;
    /* Reduced from 56px */
    height: 48px;
    /* Reduced from 56px */
    border-radius: 12px;
    background: #EFF6FF;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    /* Reduced from 1.6rem */
    margin-bottom: 0;
    flex-shrink: 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    /* Modern touch */
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.stat-label {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.next-class-highlight {
    background: #FEF3C7;
    color: #D97706;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-top: 6px;
    display: inline-block;
}

/* Payments Table Styles */
@media (min-width: 769px) {
    .payment-table {
        border-collapse: separate;
        border-spacing: 0 12px;
        width: 100%;
    }

    .payment-table tbody tr {
        background: #FFFFFF;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
        border-radius: 8px;
    }

    .payment-table td {
        padding: 16px;
        border-bottom: 1px solid #F3F4F6;
    }

    .payment-table td:first-child {
        border-top-right-radius: 8px;
        border-bottom-right-radius: 8px;
        border-right: 1px solid #F3F4F6;
    }

    .payment-table td:last-child {
        border-top-left-radius: 8px;
        border-bottom-left-radius: 8px;
        border-left: 1px solid #F3F4F6;
    }

    .payment-table thead th {
        border-bottom: none !important;
        color: var(--text-muted);
    }

    /* Fix for edge-to-edge tables (no card padding) */
    .card[style*="padding: 0"] .payment-table,
    .card[style*="padding:0"] .payment-table {
        border-collapse: collapse;
        border-spacing: 0;
    }

    .card[style*="padding: 0"] .payment-table tbody tr,
    .card[style*="padding:0"] .payment-table tbody tr {
        box-shadow: none;
        border-radius: 0;
    }

    .card[style*="padding: 0"] .payment-table td,
    .card[style*="padding:0"] .payment-table td {
        border-radius: 0;
    }

}

/* Attendance Table - Full Table View always (Mobile & Desktop) */
.attendance-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    table-layout: auto;
    /* Allow content to dictate width, but constrain to 100% */
}

.attendance-table thead tr {
    background: #F9FAFB;
    border-bottom: 2px solid #E5E7EB;
}

.attendance-table th,
.attendance-table td {
    padding: 14px 16px;
    text-align: right;
    border-bottom: 1px solid #E5E7EB;
}

.attendance-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
}

.attendance-table td {
    color: var(--text-main);
    font-size: 0.9rem;
}

/* Dark mode for attendance table */
body.dark-mode .attendance-table thead tr {
    background: rgba(31, 41, 55, 0.5);
    border-color: #374151;
}

body.dark-mode .attendance-table th,
body.dark-mode .attendance-table td {
    border-color: #374151;
}

body.dark-mode .attendance-table th {
    color: #D1D5DB;
}

body.dark-mode .attendance-table td {
    color: #E5E7EB;
}

/* Tooltip Styles */
.tooltip-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.info-icon {
    background: #FEF3C7;
    color: #D97706;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    cursor: help;
    transition: 0.2s;
}

.info-icon:hover {
    background: #FDE68A;
}

.tooltip-content {
    visibility: hidden;
    width: max-content;
    max-width: 250px;
    background-color: #1F2937;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px 12px;
    position: absolute;
    z-index: 20;
    bottom: 130%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 0.85rem;
    pointer-events: none;
    line-height: 1.4;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.tooltip-content::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #1F2937 transparent transparent transparent;
}

.tooltip-wrap:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
}

/* Responsive Table */
/* Responsive Table: Fit All Sessions (No Scroll) */
@media (max-width: 768px) {
    .payment-table {
        display: block;
        width: 100%;
        border: none;
        background: transparent;
    }

    .payment-table thead {
        display: none;
    }

    .payment-table tbody {
        display: block;
        background: transparent;
    }

    .payment-table tr {
        display: block;
        background: var(--bg-white);
        border: 1px solid rgba(37, 99, 235, 0.15);
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 16px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
        position: relative;
    }

    .payment-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0 !important;
        font-size: 0.9rem !important;
        border-bottom: 1px solid #F3F4F6;
        height: auto !important;
        text-align: right !important;
        white-space: normal !important;
        color: var(--text-main);
    }

    .payment-table td:last-child {
        border-bottom: none;
    }

    .payment-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.85rem;
        margin-left: 12px;
    }

    /* Override widths from desktop/default */
    .payment-table td:first-child {
        border-radius: 0;
        border-right: none;
        width: 100% !important;
    }

    /* Make amount stand out */
    .payment-table td[data-label="المبلغ"] {
        color: var(--primary) !important;
        font-size: 1rem !important;
        font-weight: 700;
    }
}

/* Mobile Tooltip Fix */
.tooltip-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 300px;
    bottom: auto;
    margin: 0;
    z-index: 9999;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

/* ================= DARK MODE FIXES ================= */
body.dark-mode .notif-card,
body.dark-mode .mobile-tab {
    background-color: var(--bg-card) !important;
    border-color: #374151 !important;
    color: var(--text-main) !important;
}

body.dark-mode .stat-card {
    background-color: var(--bg-card) !important;
    border-color: #374151;
}

body.dark-mode .stat-icon {
    background-color: #374151 !important;
    /* Override inline styles */
    color: var(--primary) !important;
}

body.dark-mode .day-header {
    background-color: #374151;
    border-color: #4B5563;
    color: white;
}

body.dark-mode .child-pill {
    background-color: var(--bg-card);
    border-color: #4B5563;
    color: var(--text-muted);
}

body.dark-mode .child-pill.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

body.dark-mode .payment-table tbody tr {
    background-color: var(--bg-card);
    border-color: #374151;
}

body.dark-mode .payment-table td {
    border-color: #374151;
}

/* Dark mode for select and input fields */
body.dark-mode select,
body.dark-mode input[type="text"],
body.dark-mode input[type="email"],
body.dark-mode input[type="password"],
body.dark-mode input[type="number"],
body.dark-mode textarea {
    background-color: #1F2937 !important;
    color: var(--text-main) !important;
    border-color: #4B5563 !important;
}

body.dark-mode .screen-title {
    color: var(--primary);
}

body.dark-mode .group-name {
    color: var(--primary);
    /* Brighter blue than primary-dark */
}

body.dark-mode select option {
    background-color: #1F2937;
    color: var(--text-main);
}

body.dark-mode select:focus,
body.dark-mode input:focus,
body.dark-mode textarea:focus {
    border-color: var(--primary) !important;
    outline: none;
}

body.dark-mode .modal-content {
    background-color: var(--bg-card);
    color: var(--text-main);
}

body.dark-mode .sidebar {
    background-color: var(--bg-card);
    border-color: #374151;
}

body.dark-mode .nav-item {
    color: var(--text-muted);
}

body.dark-mode .nav-item:hover,
body.dark-mode .nav-item.active {
    background-color: #374151;
    /* Dark Gray for active item */
    color: white;
}

body.dark-mode .sidebar-header {
    border-color: #374151;
    color: white;
}

body.dark-mode .header-profile {
    border-color: #374151;
}

body.dark-mode .mobile-header {
    background-color: var(--bg-card);
    border-color: #374151;
}

/* Notification Dropdown */
.notif-dropdown {
    position: absolute;
    top: 50px;
    left: -10px;
    /* Align relative to icon */
    width: 320px;
    background: var(--bg-white);
    border: 1px solid #E5E7EB;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    z-index: 1001;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.notif-dropdown.show {
    display: flex;
    animation: fadeIn 0.1s ease-out;
}

.notif-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid #F3F4F6;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #F9FAFB;
}

.notif-dropdown-body {
    max-height: 350px;
    overflow-y: auto;
}

.mini-notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid #F3F4F6;
    display: flex;
    gap: 12px;
    transition: background 0.2s;
    cursor: pointer;
}

.mini-notif-item:hover {
    background: #F9FAFB;
}

.mini-notif-item:last-child {
    border-bottom: none;
}

body.dark-mode .notif-dropdown {
    background-color: var(--bg-card);
    border-color: #374151;
}

body.dark-mode .notif-dropdown-header {
    background-color: #374151;
    border-color: #4B5563;
    color: white;
}

body.dark-mode .mini-notif-item {
    border-color: #374151;
}

body.dark-mode .mini-notif-item:hover {
    background-color: #374151;
}

body.dark-mode .enroll-header {
    background-color: #374151;
    /* Dark Gray Header */
    border-color: #4B5563;
}

body.dark-mode .enroll-card {
    border-color: #374151;
    background-color: var(--bg-card);
}

/* Attendance Progress Chart */
.circular-chart {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: conic-gradient(var(--primary) 0%, #E5E7EB 0%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.5s ease-out;
}

.circular-chart::before {
    content: "";
    position: absolute;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: white;
}

body.dark-mode .circular-chart {
    background: conic-gradient(var(--primary) 0%, #374151 0%);
}

body.dark-mode .circular-chart::before {
    background: var(--bg-card);
}

.percentage {
    position: relative;
    font-weight: 700;
    color: var(--text-main);
    font-size: 1.1rem;
    direction: ltr;
    /* Ensure % sign is correct */
}

/* Attendance Badges */
.attendance-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-present {
    background: #ECFDF5;
    color: var(--success);
}

.badge-absent {
    background: #FEF2F2;
    color: var(--danger);
}

.badge-excused {
    background: #FFFBEB;
    color: var(--accent);
}

body.dark-mode .badge-present {
    background: rgba(16, 185, 129, 0.2);
    color: #34D399;
}

body.dark-mode .badge-absent {
    background: rgba(239, 68, 68, 0.2);
    color: #F87171;
}

body.dark-mode .badge-excused {
    background: rgba(245, 158, 11, 0.2);
    color: #FBBF24;
}

/* Table Details */
.att-group-name {
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.9rem;
    display: block;
}

.att-session-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: block;
}

body.dark-mode .payment-table thead tr {
    background-color: #374151 !important;
    color: white;
}

body.dark-mode .payment-table th {
    color: #D1D5DB !important;
    /* Light Gray Text */
    border-color: #4B5563;
}

/* Mobile Overrides (Placed at end to ensure priority) */
@media (max-width: 1024px) {
    #mobilePageTitle {
        display: none !important;
    }

    .notif-dropdown {
        position: fixed !important;
        top: 70px !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(50%) !important;
        /* RTL: 50% moves right positive? No. */
        /* Wait, in RTL: 
           left: 50% is 50% from left edge.
           If direction is RTL, transform: translateX(-50%) moves LEFT (negative x).
           So it should be correct for centering.
        */
        transform: translateX(-50%) !important;
        width: 90% !important;
        max-width: 380px !important;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2) !important;
        z-index: 2000 !important;
    }
}

/* ============================================
   REUSABLE LOADER COMPONENT
   ============================================ */

/* Base Loader */
.loader {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    position: relative;
    animation: loader-rotate 1s linear infinite;
}

.loader::before,
.loader::after {
    content: "";
    box-sizing: border-box;
    position: absolute;
    inset: 0px;
    border-radius: 50%;
    border: 5px solid var(--primary);
    animation: loader-clip 2s linear infinite;
}

.loader::after {
    inset: 8px;
    transform: rotate3d(90, 90, 0, 180deg);
    border-color: var(--accent);
}

/* Loader Size Variants */
.loader.loader-sm {
    width: 24px;
    height: 24px;
}

.loader.loader-sm::before,
.loader.loader-sm::after {
    border-width: 3px;
}

.loader.loader-sm::after {
    inset: 4px;
}

.loader.loader-md {
    width: 48px;
    height: 48px;
}

.loader.loader-lg {
    width: 64px;
    height: 64px;
}

.loader.loader-lg::before,
.loader.loader-lg::after {
    border-width: 6px;
}

.loader.loader-lg::after {
    inset: 10px;
}

/* Loader Animations */
@keyframes loader-rotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes loader-clip {
    0% {
        clip-path: polygon(50% 50%, 0 0, 0 0, 0 0, 0 0, 0 0);
    }

    50% {
        clip-path: polygon(50% 50%, 0 0, 100% 0, 100% 0, 100% 0, 100% 0);
    }

    75%,
    100% {
        clip-path: polygon(50% 50%, 0 0, 100% 0, 100% 100%, 100% 100%, 100% 100%);
    }
}

/* Loader Container - Full page overlay */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    gap: 16px;
}

.loader-overlay.loader-overlay-light {
    background: rgba(255, 255, 255, 0.9);
}

body.dark-mode .loader-overlay.loader-overlay-light {
    background: rgba(31, 41, 55, 0.95);
}

.loader-overlay .loader-text {
    color: white;
    font-size: 1rem;
    font-weight: 600;
}

.loader-overlay.loader-overlay-light .loader-text {
    color: var(--text-main);
}

/* Inline Loader - for buttons and inline elements */
.loader-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Card/Section Loader */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 16px;
}

.loader-container .loader-text {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
}

/* White loader variant for dark backgrounds */
.loader.loader-white::before {
    border-color: rgba(255, 255, 255, 0.9);
}

.loader.loader-white::after {
    border-color: var(--accent);
}

/* Deep Dark Mode for Attendance Popover */
.popover-time-box {
    background: rgba(0, 0, 0, 0.03);
    padding: 10px;
    border-radius: 12px;
    margin-bottom: 5px;
    width: 100%;
}

body.dark-mode .attendance-popover {
    background: rgba(31, 41, 55, 0.98) !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

body.dark-mode .popover-time-box {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-mode #popoverDate,
body.dark-mode #popoverTime {
    color: #F3F4F6 !important;
}

body.dark-mode .popover-close {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.attendance-popover {
    max-width: 90vw;
}

/* Force Attendance Note to 1 line */
.attendance-note {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* Fallback */
}

@media (max-width: 600px) {
    .attendance-note {
        font-size: 3.2vw !important;
        /* Scale down to fit */
    }
}

/* Force Attendance Subtitle to 1 line */
.attendance-subtitle {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 600px) {
    .attendance-subtitle {
        font-size: 3.5vw !important;
    }
}

/* Attendance Widgets Responsive Fixes */
.attendance-stats-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.progress-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
}

@media (max-width: 480px) {
    .attendance-stats-wrapper {
        grid-template-columns: 1fr !important;
        /* Force single column to fit screen */
    }

    .progress-card {
        padding: 16px !important;
        gap: 12px;
    }

    .circular-chart {
        width: 60px;
        /* Optional: Scale down chart slightly */
        height: 60px;
    }
}

/* ============ Attendance Markers - Icon Only Design ============ */
.att-marker {
    background: transparent;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    transition: transform 0.2s ease;
    position: relative;
    padding: 4px;
}

.att-marker:hover {
    transform: scale(1.2);
}

.att-marker:active {
    transform: scale(0.9);
}

/* Icon Styles */
.att-marker i {
    font-size: 1.3rem;
    font-weight: 700;
}

/* Present - Green Check */
.att-marker.present i {
    color: #10B981;
}

/* Absent - Red X */
.att-marker.absent i {
    color: #EF4444;
}

/* Excused - Amber */
.att-marker.excused i {
    color: #F59E0B;
}

/* Empty - Gray dash */
.att-marker.empty {
    cursor: default;
}

.att-marker.empty i {
    color: #CBD5E1;
    font-size: 1rem;
}

.att-marker.empty:hover {
    transform: none;
}

/* Debt Badge */
.att-marker .debt-badge {
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.45rem;
    background: var(--danger);
    color: white;
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 700;
}

/* Dark Mode */
body.dark-mode .att-marker.present i {
    color: #34D399;
}

body.dark-mode .att-marker.absent i {
    color: #F87171;
}

body.dark-mode .att-marker.excused i {
    color: #FBBF24;
}

body.dark-mode .att-marker.empty i {
    color: #4B5563;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    .att-marker i {
        font-size: 1rem;
    }

    .att-marker .debt-badge {
        font-size: 0.35rem;
        padding: 0 2px;
    }
}

/* Attendance Stat Cards - Numbers Only when space is limited */
@media (max-width: 768px) {
    .stat-card.no-hover {
        padding: 10px !important;
        flex-direction: column;
        gap: 4px !important;
        min-width: 0;
        overflow: hidden;
    }

    .stat-card.no-hover .stat-icon {
        width: 32px !important;
        height: 32px !important;
        font-size: 1rem !important;
        margin-bottom: 4px !important;
    }

    .stat-card.no-hover .stat-label {
        font-size: 0.65rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .stat-card.no-hover .stat-value {
        font-size: 1.1rem !important;
    }
}

/* Even smaller screens - hide labels entirely */
@media (max-width: 400px) {
    .stat-card.no-hover .stat-icon {
        display: none !important;
    }

    .stat-card.no-hover .stat-label {
        display: none !important;
    }

    .stat-card.no-hover .stat-value {
        font-size: 1.3rem !important;
    }
}