/* ============================================
   SCHOLARSLATE — Design System CSS
   ============================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
    --primary: #1565C0;
    --primary-light: #1E88E5;
    --primary-dark: #0D47A1;
    --primary-50: #E3F2FD;
    --primary-100: #BBDEFB;

    --accent: #FF6D00;
    --accent-light: #FF9100;

    --bg: #F5F7FA;
    --bg-card: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --bg-topbar: #FFFFFF;

    --text: #1A1A2E;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --text-on-primary: #FFFFFF;

    --border: #E5E7EB;
    --border-light: #F3F4F6;

    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --error: #EF4444;
    --error-light: #FEE2E2;
    --info: #3B82F6;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.04);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    --sidebar-width: 250px;
    --topbar-height: 64px;
    --bottomnav-height: 72px;

    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* Subject colors */
    --subj-blue: #E3F2FD;
    --subj-blue-text: #1565C0;
    --subj-green: #E8F5E9;
    --subj-green-text: #2E7D32;
    --subj-orange: #FFF3E0;
    --subj-orange-text: #E65100;
    --subj-red: #FFEBEE;
    --subj-red-text: #C62828;
    --subj-purple: #F3E5F5;
    --subj-purple-text: #6A1B9A;
    --subj-teal: #E0F2F1;
    --subj-teal-text: #00695C;
    --subj-pink: #FCE4EC;
    --subj-pink-text: #AD1457;
    --subj-amber: #FFF8E1;
    --subj-amber-text: #FF6F00;

    --bg-welcome: linear-gradient(135deg, #EBF4FF 0%, #F5F7FA 50%, #E3F2FD 100%);
}

.dark-theme {
    --bg: #121212;
    --bg-card: #1E1E1E;
    --bg-sidebar: #1E1E1E;
    --bg-topbar: #1E1E1E;
    
    --text: #F3F4F6;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    
    --border: #374151;
    --border-light: #2A2A2A;
    
    --primary-50: #172554;
    --primary-100: #1E3A8A;
    --success-light: #064E3B;
    --warning-light: #78350F;
    --error-light: #7F1D1D;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.6);

    --bg-welcome: radial-gradient(circle at top right, #1E293B, #0F172A);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

/* ---------- Layout Shell ---------- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar (Desktop) ---------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition-slow);
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    flex-shrink: 0;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
}

.sidebar-brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.sidebar-brand-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.sidebar-school {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--primary-50);
    border-radius: var(--radius-sm);
    margin-top: 4px;
}

.sidebar-school-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-school-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-dark);
    line-height: 1.3;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    position: relative;
}

.nav-item:hover {
    background: var(--bg);
    color: var(--text);
}

.nav-item.active {
    background: var(--primary-50);
    color: var(--primary);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.nav-item .material-icons-outlined {
    font-size: 22px;
}

.nav-item.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.nav-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 16px 16px 4px;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-footer .nav-item {
    font-size: 0.85rem;
}

.sidebar-footer .nav-item.logout {
    color: var(--error);
}
.sidebar-footer .nav-item.logout:hover {
    background: var(--error-light);
}

/* ---------- Main Content Area ---------- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---------- Top Bar ---------- */
.topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    z-index: 90;
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.topbar-breadcrumb span {
    color: var(--text);
    font-weight: 500;
}

.topbar-hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 28px;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}
.topbar-hamburger:hover {
    background: var(--bg);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-search {
    position: relative;
    display: flex;
    align-items: center;
}

.topbar-search input {
    width: 220px;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    transition: all var(--transition-fast);
    outline: none;
}

.topbar-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.1);
    width: 280px;
}

.topbar-search .material-icons-outlined {
    position: absolute;
    left: 10px;
    font-size: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.topbar-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--bg);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}
.topbar-icon-btn:hover {
    background: var(--primary-50);
    color: var(--primary);
}

.topbar-icon-btn .badge-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--error);
    border-radius: 50%;
    border: 2px solid white;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 4px 4px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.topbar-user:hover {
    background: var(--bg);
}

.topbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
}

.topbar-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.topbar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.topbar-user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ---------- Page Content ---------- */
.page-content {
    flex: 1;
    padding: 28px;
    max-width: 1400px;
    width: 100%;
}

.page-header {
    margin-bottom: 24px;
}

.page-header-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    background: var(--primary-50);
    color: var(--primary);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.page-title {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

.page-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.page-header-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 20px 24px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.card-header-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: var(--primary-50);
    color: var(--primary);
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.card-body {
    padding: 12px 24px 24px;
}

.card-badge {
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.card-badge.live {
    background: var(--success-light);
    color: var(--success);
}
.card-badge.warning {
    background: var(--warning-light);
    color: var(--warning);
}

/* ---------- Current Lesson Card (Hero) ---------- */
.hero-card {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-xl);
    padding: 28px;
    color: white;
    position: relative;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(21, 101, 192, 0.25);
}

.hero-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 300px;
    height: 300px;
    background: rgba(255,255,255,0.06);
    border-radius: 50%;
}

.hero-card::after {
    content: '';
    position: absolute;
    bottom: -40%;
    left: -10%;
    width: 200px;
    height: 200px;
    background: rgba(255,255,255,0.04);
    border-radius: 50%;
}

.hero-card-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.hero-card-title {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 6px;
    position: relative;
    z-index: 1;
}

.hero-card-sub {
    font-size: 0.9rem;
    opacity: 0.85;
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
}

.hero-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}

.hero-card-time {
    font-size: 0.95rem;
    font-weight: 600;
}

.hero-card-progress {
    flex: 1;
    max-width: 200px;
    height: 5px;
    background: rgba(255,255,255,0.25);
    border-radius: 10px;
    margin: 0 16px;
    overflow: hidden;
}

.hero-card-progress-bar {
    height: 100%;
    background: white;
    border-radius: 10px;
    transition: width 1s ease;
}

.hero-card-icon {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    position: absolute;
    top: 24px;
    right: 24px;
}

/* ---------- Info Cards Row ---------- */
.info-cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.info-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
}

.info-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.info-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.info-card-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.info-card-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.info-card-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.info-card-sub {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.4;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(21, 101, 192, 0.2);
}
.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 6px 20px rgba(21, 101, 192, 0.4), 0 0 0 2px rgba(21, 101, 192, 0.1);
    transform: translateY(-2px);
}

.btn-outline {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}
.btn-outline:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}
.btn-success:hover {
    background: #059669;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--error);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
    background: #DC2626;
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
    transform: translateY(-2px);
}


.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}
.btn-ghost:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ---------- Form Elements ---------- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--bg-card);
    transition: all var(--transition-fast);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8.825L.6 3.425 1.4 2.6 6 7.2l4.6-4.6.8.825z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

body.dark-theme select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239CA3AF' d='M6 8.825L.6 3.425 1.4 2.6 6 7.2l4.6-4.6.8.825z'/%3E%3C/svg%3E");
}

select.form-control:disabled {
    background-color: var(--bg);
    cursor: not-allowed;
    opacity: 0.6;
}

input[type="file"].form-control {
    padding: 8px 14px;
}

input[type="date"].form-control {
    cursor: pointer;
}

input[type="password"].form-control {
    letter-spacing: 2px;
}

/* ---------- Tables ---------- */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    margin-top: 16px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    background: var(--bg);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 5;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: var(--primary-50);
}

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

/* Editable Table */
.data-table td[contenteditable="true"] {
    cursor: text;
    transition: background var(--transition-fast);
}

.data-table td[contenteditable="true"]:focus {
    background: #FFFDE7;
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

/* ---------- Schedule Grid (Orario) ---------- */
.schedule-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.schedule-grid th {
    background: var(--bg);
    padding: 12px 8px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    text-align: center;
}

.schedule-grid td {
    padding: 6px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: top;
    min-width: 130px;
}

.schedule-grid td.time-col {
    font-weight: 700;
    color: var(--text);
    text-align: center;
    vertical-align: middle;
    min-width: 70px;
    font-size: 0.9rem;
}

.schedule-cell {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--border);
    min-height: 60px;
    background: var(--bg);
    color: var(--text);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.schedule-cell:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

.schedule-cell .subj-name {
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 4px;
    color: var(--text);
}

.schedule-cell .subj-info {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.schedule-cell .subj-room {
    font-size: 0.7rem;
    margin-top: 4px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 3px;
}

/* Only Ed. Fisica and Laboratorio get special colors */
.schedule-cell.subj-edfisica { background: var(--subj-green); border-color: var(--subj-green-text); }
.schedule-cell.subj-edfisica .subj-name { color: var(--subj-green-text); }
.schedule-cell.subj-lab { background: var(--subj-orange); border-color: var(--subj-orange-text); }
.schedule-cell.subj-lab .subj-name { color: var(--subj-orange-text); }

/* ---------- Section / Areas ---------- */
.content-section {
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.section-title .material-icons-outlined {
    font-size: 24px;
    color: var(--primary);
}

/* ---------- Search Area ---------- */
.search-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.search-box {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.search-box-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- Realtime Box ---------- */
.realtime-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 24px;
}

.realtime-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.realtime-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Location result card */
.location-card {
    background: var(--primary-50);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
}

.location-box {
    margin-top: 12px;
}

.location-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
}

.location-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
}

/* ---------- Admin Sections ---------- */
.admin-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 24px;
}

.admin-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.admin-section-header .material-icons-outlined {
    color: var(--primary);
}

.admin-section-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* File upload area */
.file-upload-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.file-upload-item {
    background: var(--bg);
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 20px 16px;
    text-align: center;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.file-upload-item:hover {
    border-color: var(--primary);
    background: var(--primary-50);
}

.file-upload-item label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    cursor: pointer;
}

.file-upload-item input[type="file"] {
    width: 100%;
    font-size: 0.8rem;
}

.file-upload-item .material-icons-outlined {
    font-size: 32px;
    color: var(--primary);
    margin-bottom: 8px;
}

/* Editable table container */
.edit-table-wrap {
    max-height: 350px;
    overflow-y: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    margin-top: 12px;
}

.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* Absences section */
.absence-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--error);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 24px;
}

.absence-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 16px;
}

.absence-form .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 180px;
}

.absence-list {
    list-style: none;
    padding: 0;
}

.absence-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background var(--transition-fast);
    border-radius: var(--radius-sm);
}

.absence-list li:hover {
    background: var(--error-light);
}

/* Substitution panel */
.subst-panel {
    margin-top: 20px;
    padding: 24px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.dark-theme .subst-panel {
    background: rgba(239, 68, 68, 0.03); /* Extremely subtle red tint */
    border-color: rgba(239, 68, 68, 0.2);
}

.subst-panel h3 {
    color: var(--error);
    margin-bottom: 8px;
    font-size: 1.2rem;
}

.subst-panel p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}


.supplenza-row {
    margin-bottom: 12px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.supplenza-row:hover {
    box-shadow: var(--shadow-sm);
    transform: translateX(4px);
}

.supplenza-row .subst-ora-label {
    font-weight: 700;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}


.supplenza-row .subst-fields {
    display: flex;
    gap: 10px;
}

.supplenza-row .subst-fields select,
.supplenza-row .subst-fields input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

.supplenza-row .subst-fields select:focus,
.supplenza-row .subst-fields input:focus {
    border-color: var(--primary);
    outline: none;
}


/* ---------- Bulletin ---------- */
.bulletin-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    border-top: 4px solid var(--primary);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 24px;
}

.bulletin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.bulletin-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.hour-block {
    margin-bottom: 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.hour-block-header {
    background: var(--bg);
    padding: 10px 16px;
    font-weight: 700;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-light);
}

/* ---------- Global Loader ---------- */
.global-loader {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg);
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.global-loader.fade-out {
    opacity: 0;
    visibility: hidden;
}

.global-loader-content {
    text-align: center;
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.global-loader-icon {
    width: 80px; height: 80px;
    background: var(--primary);
    color: white;
    border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 24px auto;
    box-shadow: 0 10px 25px rgba(26, 115, 232, 0.4);
    animation: floatBounce 2s infinite ease-in-out;
}

.global-loader-icon span { font-size: 40px; }

.global-loader-title {
    font-size: 1.5rem; font-weight: 800; color: var(--text);
    margin-bottom: 8px;
}

.global-loader-subtitle {
    font-size: 1rem; color: var(--text-secondary);
    margin-bottom: 32px;
}

.global-loader-progress {
    width: 220px; height: 6px;
    background: var(--border);
    border-radius: 6px;
    margin: 0 auto;
    overflow: hidden;
    position: relative;
}

.global-loader-bar {
    position: absolute; top: 0; left: 0; height: 100%;
    width: 0%;
    background: var(--primary);
    border-radius: 6px;
    transition: width 0.8s ease-out;
}

@keyframes floatBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* ---------- Welcome Screen ---------- */
#welcomeScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-welcome);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
}

.welcome-card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-xl);
    text-align: center;
    position: relative;
    overflow: hidden;
    animation: slideUp 0.6s ease-out;
}

.welcome-theme-toggle {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    z-index: 10;
}
.welcome-theme-toggle:hover {
    background: var(--primary-50);
    color: var(--primary);
    transform: rotate(15deg);
}


@keyframes welcomeFadeIn {
    from { opacity: 0; transform: translateY(30px) scale(0.95); filter: blur(10px); }
    to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.welcome-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 32px;
    margin: 0 auto 20px;
    box-shadow: 0 8px 24px rgba(21, 101, 192, 0.3);
}

.welcome-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.welcome-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.role-btn-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-role {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 18px 28px;
    border: none;
    border-radius: var(--radius-lg);
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: white;
    width: 100%;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.btn-role::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(255,255,255,0.15), transparent);
    pointer-events: none;
}

.btn-role:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 24px rgba(0,0,0,0.15);
}

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

.btn-role-student {
    background: linear-gradient(135deg, #1A73E8 0%, #1557B0 100%);
}
.btn-role-student:hover {
    box-shadow: 0 12px 24px rgba(26, 115, 232, 0.3);
}

.btn-role-staff {
    background: linear-gradient(135deg, #34A853 0%, #1E8E3E 100%);
}
.btn-role-staff:hover {
    box-shadow: 0 12px 24px rgba(52, 168, 83, 0.3);
}

.btn-role-admin {
    background: linear-gradient(135deg, #9333EA 0%, #7E22CE 100%);
}
.btn-role-admin:hover {
    box-shadow: 0 12px 24px rgba(147, 51, 234, 0.3);
}

/* Animations for sub-menus */
.animate-slide-down {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transform: translateY(-10px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    visibility: hidden;
}

.animate-slide-down.show {
    max-height: 500px; /* Large enough for content */
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}


.welcome-form-step {
    display: none;
    text-align: left;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-light);
    animation: welcomeFadeIn 0.3s ease;
}

.welcome-form-step h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}

.welcome-form-step .form-group {
    margin-bottom: 14px;
}

.welcome-error {
    color: var(--error);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 10px;
    display: none;
}

/* Segmented Control (ATA / Docente) */
.segmented-control {
    position: relative;
    display: flex;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 4px;
    margin-bottom: 24px;
    user-select: none;
}

.segmented-control input[type="radio"] {
    display: none;
}

.segmented-control label {
    flex: 1;
    text-align: center;
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 2;
    transition: color 0.3s ease;
}

.segmented-control input[type="radio"]:checked + label {
    color: white;
}

.segmented-control-slider {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
    box-shadow: 0 2px 6px rgba(21, 101, 192, 0.3);
}

#staffDocente:checked ~ .segmented-control-slider {
    transform: translateX(100%);
}

#staffDocente:checked ~ .segmented-control-slider {
    background: var(--success);
    box-shadow: 0 2px 6px rgba(52, 168, 83, 0.3);
}

#staffATA:checked ~ .segmented-control-slider {
    background: #546E7A; /* ATA Color */
    box-shadow: 0 2px 6px rgba(84, 110, 122, 0.3);
}

.btn-back {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    margin-top: 20px;
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-back:hover {
    background: var(--bg-card);
    color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(21, 101, 192, 0.1), 0 0 10px rgba(21, 101, 192, 0.1);
    transform: translateX(-4px);
}

.btn-back:active {
    transform: scale(0.98) translateX(-2px);
}


/* ---------- Bottom Navigation (Mobile) ---------- */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottomnav-height);
    background: white;
    border-top: 1px solid var(--border);
    z-index: 100;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
}

.bottom-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 100%;
    padding: 0 8px;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 16px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    position: relative;
}

.bottom-nav-item .material-icons-outlined {
    font-size: 24px;
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    width: 20px;
    height: 3px;
    background: var(--primary);
    border-radius: 3px;
}

/* ---------- Spinner ---------- */
.spinner-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.7);
    backdrop-filter: blur(4px);
    z-index: 9998;
    align-items: center;
    justify-content: center;
}

.spinner-overlay.show {
    display: flex;
}

.spinner {
    display: none;
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 10px auto;
}

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

/* ---------- Status ---------- */
.status-msg {
    text-align: center;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.status-error {
    color: var(--error);
    background: var(--error-light);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
}

.status-ok {
    color: var(--success);
    background: var(--success-light);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
}

/* ---------- Result Panel ---------- */
.result-panel {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-top: 20px;
    min-height: 80px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
}

/* ---------- Sidebar Overlay (Mobile) ---------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 99;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
    display: block;
}

/* ---------- Select2 Override ---------- */
.select2-container--default .select2-selection--single {
    height: 48px; /* Match form-control height */
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md) !important;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
}

.select2-container--open .select2-selection--single {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.2);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: normal;
    padding-left: 16px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 48px;
    right: 12px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: var(--text-muted) transparent transparent transparent;
}

/* Dropdown styling & Animation */
.select2-dropdown {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-md) !important;
    background-color: var(--bg-card) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2) !important;
    overflow: hidden;
    /* Smooth bounce slide down */
    animation: select2SlideDown 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transform-origin: top;
    z-index: 99999 !important;
}

.select2-container--open {
    z-index: 99999 !important;
}

@keyframes select2SlideDown {
    from {
        opacity: 0;
        transform: scaleY(0.9) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scaleY(1) translateY(0);
    }
}

/* Search Box */
.select2-search--dropdown {
    padding: 12px !important;
    background-color: var(--bg-card);
}

.select2-search--dropdown .select2-search__field {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    padding: 10px 14px !important;
    background-color: var(--bg) !important;
    color: var(--text) !important;
    font-family: inherit;
    transition: border-color 0.2s;
}

.select2-search--dropdown .select2-search__field:focus {
    outline: none;
    border-color: var(--primary) !important;
}

/* Options */
.select2-results__options {
    max-height: 250px !important;
    padding: 6px !important;
}

.select2-results__option {
    padding: 10px 16px !important;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    color: var(--text) !important;
    transition: background-color 0.2s, color 0.2s;
}

.select2-results__option--highlighted[aria-selected],
.select2-results__option:hover {
    background-color: var(--primary) !important;
    color: white !important;
}

.select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: var(--primary-50) !important;
    color: var(--primary) !important;
    font-weight: 600;
}

/* Dark Theme Specific Select2 Overrides */
.dark-theme .select2-dropdown {
    background-color: var(--bg-card) !important;
    border-color: var(--border) !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
}

.dark-theme .select2-container--default .select2-selection--single {
    background-color: var(--bg) !important;
    border-color: var(--border) !important;
}

.dark-theme .select2-container--open .select2-selection--single {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.3) !important;
}

.dark-theme .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text) !important;
}

.dark-theme .select2-results__option {
    color: var(--text) !important;
}

.dark-theme .select2-search--dropdown .select2-search__field {
    background-color: var(--bg) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

.dark-theme .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--primary) !important;
}

.dark-theme .select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: rgba(26, 115, 232, 0.15) !important;
}


/* ---------- Animations ---------- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    opacity: 0;
    animation: fadeInUp 0.4s ease-out forwards;
}

/* ---------- Responsive: Tablet ---------- */
@media (max-width: 1024px) {
    .page-content {
        padding: 20px;
    }

    .search-panel {
        grid-template-columns: 1fr;
    }

    .file-upload-grid {
        grid-template-columns: 1fr 1fr;
    }

    .topbar-search input {
        width: 180px;
    }
    .topbar-search input:focus {
        width: 220px;
    }

    .schedule-grid td {
        min-width: 110px;
    }

    .schedule-grid-mobile-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ---------- Responsive: Mobile ---------- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .main-content {
        margin-left: 0;
        padding-bottom: calc(var(--bottomnav-height) + 16px);
    }

    .topbar {
        padding: 0 16px;
    }

    .topbar-hamburger {
        display: flex;
    }

    .topbar-search {
        display: none;
    }

    .topbar-user-info {
        display: none;
    }

    .bottom-nav {
        display: block;
    }

    .page-content {
        padding: 16px;
    }

    .page-title {
        font-size: 1.4rem;
    }

    .hero-card {
        padding: 20px;
        border-radius: var(--radius-lg);
    }

    .hero-card-title {
        font-size: 1.3rem;
    }

    .info-cards-row {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .info-card {
        padding: 14px;
    }

    .search-panel {
        grid-template-columns: 1fr;
    }

    .file-upload-grid {
        grid-template-columns: 1fr;
    }

    .absence-form {
        flex-direction: column;
    }

    .absence-form .form-group {
        width: 100%;
    }

    .bulletin-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .bulletin-actions {
        width: 100%;
    }

    .bulletin-actions .btn {
        flex: 1;
        font-size: 0.75rem;
        padding: 8px;
    }

    .table-container {
        margin-left: -16px;
        margin-right: -16px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .welcome-card {
        padding: 32px 24px;
    }

    .welcome-title {
        font-size: 1.3rem;
    }

    .topbar-right .topbar-icon-btn:not(:last-child) {
        display: none;
    }

    /* Staff-only section single column */
    .search-panel .search-box.staff-only {
        display: none;
    }
    body.role-staff .search-panel .search-box.staff-only,
    body.role-admin .search-panel .search-box.staff-only {
        display: block;
    }
    /* Mobile: schedule as vertical cards */
    .schedule-mobile {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .schedule-mobile .schedule-day-card {
        background: var(--bg-card);
        border: 1px solid var(--border-light);
        border-radius: var(--radius-lg);
        overflow: hidden;
    }

    .schedule-mobile .schedule-day-header {
        background: var(--bg);
        padding: 10px 16px;
        font-weight: 700;
        font-size: 0.85rem;
        color: var(--text);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        border-bottom: 1px solid var(--border-light);
    }

    .schedule-mobile .schedule-day-body {
        padding: 8px;
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .schedule-mobile .schedule-hour-row {
        display: flex;
        gap: 10px;
        align-items: flex-start;
        padding: 8px;
        border-radius: var(--radius-sm);
    }

    .schedule-mobile .schedule-hour-label {
        min-width: 50px;
        font-weight: 700;
        font-size: 0.85rem;
        color: var(--text-muted);
        padding-top: 2px;
        text-align: center;
    }

    .schedule-mobile .schedule-hour-content {
        flex: 1;
    }

    .schedule-mobile .schedule-cell {
        min-height: auto;
        padding: 8px 12px;
    }

    /* Hide desktop table on mobile */
    .schedule-desktop-table {
        display: none !important;
    }

    .schedule-mobile {
        display: flex !important;
    }
}

@media (max-width: 400px) {
    .info-cards-row {
        grid-template-columns: 1fr;
    }

    .hero-card-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .hero-card-progress {
        width: 100%;
        max-width: none;
        margin: 0;
    }
}

/* ---------- Print ---------- */
@media print {
    .sidebar, .topbar, .bottom-nav, .sidebar-overlay,
    #welcomeScreen, .btn, button {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }

    .page-content {
        padding: 0 !important;
    }

    .card, .admin-section, .realtime-card, .bulletin-card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}

/* ---------- Utility Classes ---------- */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-error { color: var(--error); }
.text-success { color: var(--success); }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }

/* ---------- Logout Modal ---------- */
.logout-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--bg-card);
    width: 90%;
    max-width: 400px;
    border-radius: var(--radius-lg);
    z-index: 1000;
    padding: 30px 24px;
    text-align: center;
    box-shadow: var(--shadow-xl);
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-base);
}

.logout-modal.show {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.logout-modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.logout-modal-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--error-light);
    color: var(--error);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    margin-bottom: 8px;
}

.logout-modal h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
}

.logout-modal p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}

.logout-modal-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.logout-modal-actions .btn {
    flex: 1;
}
