:root {
    --color-primary: #1a73e8;
    --color-accent: #f9ab00;
    --color-success: #1e8e3e;
    --color-danger: #d93025;
    --color-secondary: #5f6368;
    --color-background: #f8f9fa;
    --color-dark: #202124;
    --color-light: #ffffff;
    --color-info: #1a73e8;
    --color-late: #f9ab00;
    --color-excused: #8430ce;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --border-color: #dadce0;
    --sidebar-bg: #ffffff;
    --sidebar-hover: #f1f3f4;
    --sidebar-active: #e8f0fe;
    --sidebar-active-text: #1a73e8;
    --card-shadow: 0 1px 2px 0 rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
    --card-hover-shadow: 0 1px 3px 0 rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
}

[data-theme="dark"] {
    --color-primary: #8ab4f8;
    --color-accent: #fdd663;
    --color-success: #81c995;
    --color-danger: #f28b82;
    --color-secondary: #9aa0a6;
    --color-background: #202124;
    --color-dark: #292a2d;
    --color-light: #292a2d;
    --color-info: #8ab4f8;
    --color-late: #fdd663;
    --color-excused: #c58af9;
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --border-color: #5f6368;
    --sidebar-bg: #292a2d;
    --sidebar-hover: #3c4043;
    --sidebar-active: #3c4043;
    --sidebar-active-text: #8ab4f8;
    --card-shadow: 0 1px 2px 0 rgba(0,0,0,.3), 0 1px 3px 1px rgba(0,0,0,.15);
    --card-hover-shadow: 0 1px 3px 0 rgba(0,0,0,.3), 0 4px 8px 3px rgba(0,0,0,.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Google Sans', 'Roboto', 'Segoe UI', sans-serif;
    background-color: var(--color-background);
    color: var(--text-primary);
    display: flex;
    padding-left: 0; /* Always 0, sidebar hidden by default */
    min-height: 100vh;
    transition: background-color 0s ease, color 0.3s ease, padding-left 0.3s ease;
}

@media (max-width: 768px) {
    body {
        padding-left: 0;
    }
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  min-height: 100vh;
  z-index: 1000;
  transition: all 0.3s ease;
  transform: translateX(-100%); /* Hidden by default */
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
}

.sidebar.active,
.sidebar.open {
  transform: translateX(0); /* Show when active */
}

/* Mobile Menu Toggle - Always visible */
.mobile-menu-toggle {
    display: block; /* Always visible, not just mobile */
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--text-primary);
}

.mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
}

/* Mobile Overlay */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

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

.sidebar-logo {
    font-size: 22px;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 0.25px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 8px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--sidebar-hover);
}

.nav-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-active-text);
}

.nav-item i {
    font-size: 20px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.theme-toggle-btn {
    width: 100%;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--sidebar-hover);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    transition: background-color 0.2s ease;
}

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

.logout-btn {
    width: 100%;
    padding: 12px;
    background: var(--color-danger);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.logout-btn:hover {
    opacity: 0.9;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top Bar */
.topbar {
    background: var(--color-light);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 100;
    transition: background-color 0.3s ease;
}

.page-title {
    font-size: 24px;
    font-weight: 400;
    color: var(--text-primary);
}

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

/* Button Styling */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.25px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--card-shadow);
}

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

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

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

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

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

.deleteBtn {
    background: var(--color-danger);
    color: white;
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

/* Content Sections */
.content-section {
    padding: 32px;
    animation: fadeIn 0.3s ease;
}

.section-title {
    font-size: 24px;
    font-weight: 400;
    margin-bottom: 24px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Class Card View (Google Classroom Style) */
.class-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.class-card {
    background-color: var(--color-light);
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    overflow: hidden;
    border-top: 4px solid var(--color-primary);
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

.class-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-hover-shadow);
}

.card-header {
    padding: 20px;
    background: linear-gradient(135deg, var(--color-primary) 0%, #1557b0 100%);
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.card-code {
    margin: 0;
    color: white;
    font-size: 24px;
    font-weight: 400;
    letter-spacing: 0.25px;
}

.card-name {
    margin: 8px 0 0;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
}

.card-body {
    padding: 16px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.no-records {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px;
    background: var(--color-light);
    border-radius: 8px;
    color: var(--text-secondary);
    font-style: italic;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
}

/* Summary Cards (Attendance View) */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--color-light);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    text-align: center;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.summary-card i {
    font-size: 32px;
}

.summary-card h3 {
    margin: 0;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-card p {
    font-size: 32px;
    font-weight: 400;
    margin: 0;
    color: var(--text-primary);
}

.summary-card.present {
    border-top: 4px solid var(--color-success);
}
.summary-card.present i,
.summary-card.present h3 {
    color: var(--color-success);
}

.summary-card.absent {
    border-top: 4px solid var(--color-danger);
}
.summary-card.absent i,
.summary-card.absent h3 {
    color: var(--color-danger);
}

.summary-card.late {
    border-top: 4px solid var(--color-late);
}
.summary-card.late i,
.summary-card.late h3 {
    color: var(--color-late);
}

.summary-card.excused {
    border-top: 4px solid var(--color-excused);
}
.summary-card.excused i,
.summary-card.excused h3 {
    color: var(--color-excused);
}

/* Filter and Batch Edit Controls */
.filter-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.filter-group {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-group label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background: var(--color-light);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.filter-input:focus {
    outline: none;
    border-color: var(--color-primary);
    border-width: 2px;
    padding: 7px 11px;
}

.global-actions {
    display: flex;
    justify-content: flex-end;
    padding-bottom: 12px;
    gap: 8px;
}

.global-edit-btn {
    background-color: var(--color-primary);
    color: white;
}

.global-save-btn {
    background-color: var(--color-success);
    color: white;
}

.global-cancel-btn {
    background-color: var(--color-danger);
    color: white;
}

/* Table Styles */
.table-container {
    overflow-x: auto;
    background: var(--color-light);
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
}

#attendanceTable {
    width: 100%;
    border-collapse: collapse;
}

#attendanceTable thead th {
    background-color: var(--color-primary);
    color: white;
    padding: 12px 16px;
    text-align: left;
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
}

#attendanceTable tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    font-size: 14px;
    color: var(--text-primary);
}

#attendanceTable tbody tr:hover {
    background-color: var(--color-background);
}

/* Inline Editing Fields */
.edit-field {
    padding: 6px 8px;
    border: 1px solid var(--color-accent);
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
    background: var(--color-light);
    color: var(--text-primary);
}

.status {
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background-color: var(--color-light);
    color: var(--text-primary);
    width: 100%;
    font-size: 14px;
}

/* Prediction Tool */
.prediction-tool {
    background: var(--color-light);
    padding: 24px;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    border-left: 4px solid var(--color-primary);
    border: 1px solid var(--border-color);
}

.prediction-tool h2 {
    margin-top: 0;
    font-size: 20px;
    font-weight: 400;
    color: var(--text-primary);
}

.prediction-tool p {
    color: var(--text-secondary);
    font-size: 14px;
}

#modelSelect,
#runPredictionBtn {
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 4px;
}

#modelSelect {
    border: 1px solid var(--border-color);
    background: var(--color-light);
    color: var(--text-primary);
}

#runPredictionBtn {
    background: var(--color-primary);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 500;
    margin-left: 8px;
}

#runPredictionBtn:hover {
    background: #1557b0;
}

#predictionStatus {
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .topbar {
        padding: 12px 16px;
    }

    .page-title {
        font-size: 18px;
    }

    .user-name {
        display: none;
    }

    .content-section {
        padding: 16px;
    }

    .filter-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .filter-group {
        flex-direction: column;
        align-items: stretch;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .class-grid {
        grid-template-columns: 1fr;
    }

    .topbar-actions {
        flex-wrap: wrap;
        gap: 4px;
    }

    .btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    /* Make tables scrollable on mobile */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    #attendanceTable {
        min-width: 600px;
    }

    /* Stack stats vertically on mobile */
    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .stat-card {
        padding: 16px !important;
    }

    /* Adjust quick actions for mobile */
    .quick-actions {
        grid-template-columns: 1fr !important;
    }

    /* Better spacing for mobile */
    [style*="padding: 24px 48px"] {
        padding: 16px !important;
    }

    /* Make action cards more compact */
    .action-card {
        padding: 16px !important;
    }
}

@media (max-width: 480px) {
    .topbar {
        padding: 8px 12px;
    }

    .page-title {
        font-size: 16px;
    }

    .user-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .content-section {
        padding: 12px;
    }

    .summary-card p {
        font-size: 24px;
    }

    .btn {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Profile Avatar Link */
.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-name {
  font-weight: 500;
  color: var(--text-primary);
}

.user-avatar-link {
  text-decoration: none;
  display: inline-block;
  transition: transform 0.2s ease;
}

.user-avatar-link:hover {
  transform: scale(1.05);
}

.user-avatar-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #1a73e8;
  cursor: pointer;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1a73e8;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
}

/* Clickable Class Cards */
.class-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.2s;
}

.class-card-link:hover {
    transform: translateY(-4px);
}

.class-card {
    cursor: pointer;
}

.card-stats {
    display: flex;
    gap: 20px;
    margin: 15px 0;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color, #1a73e8);
}

.card-action {
    color: var(--primary-color, #1a73e8);
    font-weight: 500;
    margin-top: 10px;
}

/* Teacher List Avatars */
.teacher-avatar-img {
  width: 50px !important;
  height: 50px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.teacher-avatar {
  width: 28px !important;
  height: 28px !important;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.teacher-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Student List Avatars */
.student-avatar-img {
  width: 50px !important;
  height: 50px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.student-avatar {
  width: 50px !important;
  height: 50px !important;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.student-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

