/* ============================================
   ISEF Gestion - Student Management System
   ============================================ */

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --transition: all 0.2s ease;
}

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

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease, opacity 0.2s ease;
}

a:hover {
  opacity: 0.85;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; transition: background 0.2s ease; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ===== App Layout ===== */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-container--full {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* ===== Top Navigation Bar ===== */
.top-navbar {
  background: var(--gray-900);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 8px;
}

.top-navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.top-navbar-brand i {
  font-size: 24px;
  color: var(--primary-light);
}

.top-navbar-brand h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.top-navbar-nav-wrapper {
  display: flex;
  align-items: center;
  flex: 1;
  /* overflow intentionally not set to avoid clipping dropdown menus */
}

.top-navbar-nav-wrapper::-webkit-scrollbar {
  display: none;
}

.top-navbar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  color: var(--gray-300);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
}

.nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.nav-link.active {
  background: var(--primary);
  color: white;
}

/* Nav Dropdown */
.nav-dropdown {
  position: relative;
}

/* Desktop hover: invisible bridge so hover isn't lost when moving to the menu */
@media (min-width: 768px) {
  .nav-dropdown::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 8px;
  }

  .nav-dropdown:hover > .nav-dropdown-menu {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }

  .nav-dropdown:hover > .nav-dropdown-toggle i:last-child {
    transform: rotate(180deg);
  }
}

.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  color: var(--gray-300);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-family: inherit;
}

.nav-dropdown-toggle:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.nav-dropdown-toggle i:last-child {
  font-size: 10px;
  margin-left: 2px;
  transition: transform 0.2s ease;
}

.nav-dropdown--open .nav-dropdown-toggle i:last-child {
  transform: rotate(180deg);
}

.nav-dropdown-toggle i {
  width: 16px;
  text-align: center;
  font-size: 14px;
}

.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 210px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  margin-top: 8px;
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
}

.nav-dropdown--open .nav-dropdown-menu {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.nav-dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: var(--gray-700);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: 4px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-dropdown-menu a:hover {
  background: var(--gray-50);
  color: var(--primary);
}

.nav-dropdown-menu a.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-dropdown-menu a i {
  width: 18px;
  text-align: center;
  font-size: 14px;
  color: var(--gray-400);
  transition: color 0.15s ease;
}

.nav-dropdown-menu a:hover i {
  color: var(--primary);
}

/* User info in top navbar */
.top-navbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}

.top-navbar-user .user-name {
  color: white;
}

.top-navbar-user .logout-btn {
  color: var(--gray-400);
  text-decoration: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.top-navbar-user .logout-btn:hover {
  color: var(--danger);
  background: rgba(239,68,68,0.1);
}

/* User info shared styles */
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: white;
  transition: all 0.25s ease;
}

.user-info:hover .user-avatar {
  transform: scale(1.05);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.2);
}

.user-details {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
}

.user-role {
  font-size: 11px;
  text-transform: capitalize;
  display: flex;
  align-items: center;
  gap: 4px;
}

.user-role i {
  font-size: 10px;
  width: 14px;
  text-align: center;
}

.role-admin { color: #a5b4fc; }
.role-teacher { color: #67e8f9; }
.role-administrativo { color: #fcd34d; }
.role-student { color: #6ee7b7; }

/* Mobile menu button */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--gray-300);
  cursor: pointer;
  padding: 8px;
  margin-left: auto;
}

/* Mobile nav overlay */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 98;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.mobile-nav-overlay--visible {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* Mobile user section (shown in mobile menu) */
.mobile-user-section {
  display: none;
}


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

.main-content--full {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Page Title Bar ===== */
.page-title-bar {
  background: white;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 56px;
  z-index: 50;
}

.page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-800);
  flex: 1;
}

.page-title-bar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-bar-date {
  font-size: 13px;
  color: var(--gray-500);
}

.content-wrapper {
  padding: 24px 32px;
}

/* ===== Alert Messages ===== */
.alert {
  margin: 0 32px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.3s ease, transform 0.3s ease;
  position: relative;
}

.alert-success {
  background: var(--success-light);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-error {
  background: var(--danger-light);
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: inherit;
  opacity: 0.5;
  padding: 0 4px;
}

.alert-close:hover { opacity: 1; }

/* ===== Cards ===== */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
}

.card-body {
  padding: 24px;
}

.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

/* ===== Stats Cards ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

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

.stat-card:active {
  transform: translateY(0);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-icon.blue { background: #e0e7ff; color: #4338ca; }
.stat-icon.green { background: #d1fae5; color: #059669; }
.stat-icon.yellow { background: #fef3c7; color: #d97706; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.purple { background: #f3e8ff; color: #9333ea; }
.stat-icon.cyan { background: #cffafe; color: #0891b2; }

.stat-info h4 {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1.2;
}

.stat-info p {
  font-size: 13px;
  color: var(--gray-500);
  font-weight: 500;
}

/* ===== Tables ===== */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th {
  background: var(--gray-50);
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

table td {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
}

table tbody tr {
  transition: var(--transition);
}

table tbody tr:hover {
  background: var(--gray-50);
  box-shadow: inset 3px 0 0 var(--primary);
}

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

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  transition: all 0.25s ease;
}

.badge:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}

.badge-success { background: var(--success-light); color: #065f46; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-info { background: var(--info-light); color: #1e40af; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-primary { background: #e0e7ff; color: #4338ca; }
.badge-administrativo { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  white-space: nowrap;
  line-height: 1.5;
  touch-action: manipulation;
}

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

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-200);
}

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

.btn-success:hover {
  background: #059669;
}

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

.btn-danger:hover {
  background: #dc2626;
}

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

.btn-warning:hover {
  background: #d97706;
}

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

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

.btn-icon {
  padding: 8px;
  min-width: 36px;
  justify-content: center;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--gray-800);
  background: white;
  transition: var(--transition);
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.form-control::placeholder {
  color: var(--gray-400);
}

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 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-image 0.2s ease;
}

select.form-control:focus {
  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='%234f46e5' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.form-hint {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-200);
  margin-top: 24px;
}

/* ===== Filter Bar ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: white;
  padding: 16px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.filter-bar .form-control {
  width: auto;
  min-width: 140px;
}

.filter-bar .btn {
  margin-left: 0;
}

.filter-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  line-height: 1.3;
}

/* ===== Dropdown / Export Menu ===== */
.dropdown {
  position: relative;
  display: inline-block;
}

.export-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 1000; /* Above card/stat-card animations that create stacking contexts via transform */
  min-width: 140px;
  margin-top: 4px;
  padding: 4px;
  opacity: 0;
  transform: translateY(-4px) scale(0.96);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.export-menu[style*="display: block"],
.export-menu[style*="display:block"] {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.export-menu .dropdown-item {
  display: block;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--gray-700);
  font-size: 13px;
  border-radius: 4px;
  transition: background 0.15s ease, transform 0.15s ease, padding-left 0.15s ease;
}

.export-menu .dropdown-item:hover {
  background: var(--gray-50);
  transform: translateX(4px);
}

.export-menu .dropdown-item:hover {
  background: var(--gray-50);
}

.export-menu .dropdown-item i {
  width: 18px;
  text-align: center;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.date-time-group {
  display: flex;
  gap: 4px;
}

.date-time-group .form-control {
  min-width: 0;
}

@media (max-width: 768px) {
  .date-time-group {
    flex-direction: column;
    gap: 8px;
  }
}

@media (max-width: 768px) {
  .filter-actions {
    width: 100%;
    margin-left: 0;
    flex-wrap: wrap;
  }
  
  .filter-actions .btn {
    flex: 1;
    justify-content: center;
  }
  
  .export-menu {
    right: auto;
    left: 0;
    width: calc(100vw - 32px);
    max-width: 280px;
  }
}

/* ===== Search ===== */
.search-box {
  position: relative;
}

.search-box input {
  padding-left: 36px;
}

.search-box i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 14px;
  transition: color 0.2s ease;
  pointer-events: none;
}

.search-box:focus-within i {
  color: var(--primary);
}

/* ===== Action buttons in table ===== */
.action-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
}

/* ===== Video Background ===== */
.video-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.video-background--visible {
  opacity: 1;
}

.video-background video {
  position: absolute;
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  transform: translate(-50%, -50%);
  object-fit: cover;
}

.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
}

/* ===== Login Page ===== */
.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 40px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  font-size: 48px;
  color: white;
  margin-bottom: 12px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.login-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: white;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.login-header p {
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  margin-top: 4px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.login-form .btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  justify-content: center;
}

.login-form .form-group:last-of-type {
  margin-bottom: 24px;
}

/* Form labels on transparent login card */
.login-form .form-label {
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Form inputs on transparent login card */
.login-form .form-control {
  background: rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: white;
}

.login-form .form-control:focus {
  background: rgba(255, 255, 255, 0.35);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
}

.login-form .form-control::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

/* Demo accounts section on transparent card */
.login-container > div:last-child {
  border-top-color: rgba(255, 255, 255, 0.2) !important;
}

.login-container > div:last-child p {
  color: rgba(255, 255, 255, 0.7) !important;
}

.login-container > div:last-child strong {
  color: rgba(255, 255, 255, 0.95);
}

/* Register links on transparent card */
.login-container a[href^="/registro"] {
  color: rgba(255, 255, 255, 0.9) !important;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.login-container a[href^="/registro"]:hover {
  color: white !important;
  text-decoration: underline;
}

/* ===== Dashboard Widgets ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.widget {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
}

.widget::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.12);
}

.widget:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: 0 20px 40px -12px rgba(79, 70, 229, 0.18),
              0 8px 16px -6px rgba(0, 0, 0, 0.08);
}

.widget:hover::after {
  opacity: 1;
}

.widget:hover .widget-header {
  border-bottom-color: rgba(79, 70, 229, 0.08);
}

.widget-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color 0.35s ease;
}

.widget-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
}

.widget-body {
  padding: 16px 20px;
}

.widget-list {
  list-style: none;
}

.widget-list li {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.25s ease, padding-left 0.25s ease;
  border-radius: 6px;
  margin: 0 -12px;
}

.widget-list li:last-child {
  border-bottom: none;
}

.widget-list li:hover {
  background: var(--gray-50);
  padding-left: 16px;
}

.widget-list li:hover .item-title {
  color: var(--primary);
}

.widget-list .item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.widget-list .item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-800);
  transition: color 0.25s ease;
}

.widget-list .item-subtitle {
  font-size: 12px;
  color: var(--gray-500);
  transition: color 0.25s ease;
}

.widget-list li:hover .item-subtitle {
  color: var(--gray-700);
}

.widget-list .item-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  transition: color 0.25s ease, transform 0.25s ease;
}

.widget-list li:hover .item-value {
  transform: scale(1.05);
}

/* Progress Bar */
.progress-bar {
  height: 8px;
  background: var(--gray-200);
  border-radius: 9999px;
  overflow: hidden;
  margin-top: 4px;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.5s ease;
}

/* ===== Detail Page ===== */
.detail-header {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 20px;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

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

.detail-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.detail-info h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--gray-800);
}

.detail-info p {
  font-size: 14px;
  color: var(--gray-500);
  margin-top: 4px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
}

.detail-meta span {
  font-size: 13px;
  color: var(--gray-600);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.detail-meta span:hover {
  background: var(--gray-50);
  color: var(--primary);
}

.detail-meta i {
  color: var(--gray-400);
  transition: color 0.2s ease;
}

.detail-meta span:hover i {
  color: var(--primary);
}

.detail-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* ===== Info Grid ===== */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.info-item:hover {
  background: var(--gray-50);
}

.info-item label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.2s ease;
}

.info-item:hover label {
  color: var(--primary);
}

.info-item span {
  font-size: 14px;
  color: var(--gray-800);
}

/* ===== Subject Group ===== */
.subject-group {
  border-bottom: 1px solid var(--gray-200);
}

.subject-group:last-child {
  border-bottom: none;
}

.subject-group-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 2;
}

.subject-group-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--primary);
  color: white;
  letter-spacing: 0.5px;
  line-height: 1.4;
}

.subject-group-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
}

.subject-group-count {
  font-size: 12px;
  color: var(--gray-400);
  margin-left: auto;
  font-weight: 500;
}

.subject-group .table-container table thead th {
  background: white;
}

.subject-group .table-container table tbody tr:last-child td {
  border-bottom: 1px solid var(--gray-100);
}

.subject-group:last-child .table-container table tbody tr:last-child td {
  border-bottom: none;
}

@media (max-width: 768px) {
  .subject-group-header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .subject-group-count {
    margin-left: 0;
    width: 100%;
  }
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
  transition: var(--transition);
}

.empty-state:hover {
  background: rgba(0,0,0,0.01);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  transition: transform 0.3s ease;
}

.empty-state:hover i {
  transform: scale(1.1);
}

.empty-state h3 {
  font-size: 18px;
  color: var(--gray-600);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
}

/* ===== Grade Input ===== */
.grade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.grade-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.grade-item:hover {
  background: var(--gray-100);
}

.grade-item .student-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.grade-item input {
  width: 80px;
  padding: 6px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 14px;
  text-align: center;
  transition: var(--transition);
  background: white;
}

.grade-item input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

/* ===== Attendance Marking ===== */
.attendance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.attendance-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  border-left: 4px solid transparent;
  transition: var(--transition);
}

.attendance-item.present { border-left-color: var(--success); }
.attendance-item.absent { border-left-color: var(--danger); }
.attendance-item.late { border-left-color: var(--warning); }
.attendance-item.excused { border-left-color: var(--info); }

.attendance-status {
  display: flex;
  gap: 4px;
}

.status-btn {
  padding: 4px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  transition: var(--transition);
}

.status-btn:hover { border-color: var(--gray-400); }
.status-btn.active-present { background: var(--success); color: white; border-color: var(--success); }
.status-btn.active-absent { background: var(--danger); color: white; border-color: var(--danger); }
.status-btn.active-late { background: var(--warning); color: white; border-color: var(--warning); }
.status-btn.active-excused { background: var(--info); color: white; border-color: var(--info); }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 20px;
}

.tab {
  padding: 12px 20px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  position: relative;
}

.tab::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--primary);
  transition: width 0.2s ease, left 0.2s ease;
  transform: translateX(-50%);
}

.tab:hover { color: var(--gray-700); }
.tab:hover::after { width: 40%; }

.tab.active {
  color: var(--primary);
}

.tab.active::after {
  width: 100%;
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: tabContentFadeIn 0.3s ease both; }

@keyframes tabContentFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Loading Spinner ===== */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ===== Responsive ===== */

/* iOS safe area support */
@supports (padding: max(0px)) {
  .top-navbar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .page-title-bar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}

/* Better touch targets globally */
@media (hover: none) and (pointer: coarse) {
  .btn, .nav-link, .nav-dropdown-toggle, .status-btn, .tab, .logout-btn, .alert-close {
    min-height: 44px;
    min-width: 44px;
  }
  .btn-sm { min-height: 40px; }
  .btn-icon { min-height: 44px; min-width: 44px; }
  select.form-control { min-height: 48px; }
  input.form-control { min-height: 48px; }
  .status-btn { min-height: 40px; padding: 8px 12px; }
  .action-buttons .btn { min-height: 40px; min-width: 40px; }
}

/* ===== Responsive: Narrow Desktop & Tablet (768px–1024px) ===== */
@media (min-width: 768px) and (max-width: 1024px) {
  .top-navbar {
    padding: 0 16px;
  }

  .nav-link, .nav-dropdown-toggle {
    padding: 8px 10px;
    font-size: 12px;
  }

  .nav-dropdown-toggle i {
    width: 14px;
    font-size: 13px;
  }

  .top-navbar-user .user-name {
    display: none;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .info-grid {
    grid-template-columns: 1fr 1fr;
  }
  .content-wrapper {
    padding: 20px 24px;
  }
}

/* Tablet touch targets for desktop navbar */
@media (min-width: 768px) and (max-width: 1024px) and (hover: none) and (pointer: coarse) {
  .nav-link, .nav-dropdown-toggle {
    min-height: 44px;
    padding: 10px 12px;
  }
}

/* ===== Responsive: Mobile (max 767px) ===== */
@media (max-width: 767px) {
  .top-navbar {
    padding: 0 16px;
    height: 52px;
  }

  .top-navbar-brand h2 {
    font-size: 15px;
  }

  .top-navbar-nav-wrapper {
    display: none;
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gray-900);
    z-index: 99;
    padding: 12px 16px 24px;
    overflow-y: auto;
  }

  .top-navbar-nav-wrapper.mobile-nav--open {
    display: flex;
    flex-direction: column;
  }

  .top-navbar-nav {
    flex-direction: column;
    width: 100%;
    gap: 2px;
  }

  .nav-link {
    padding: 12px 16px;
    font-size: 15px;
  }

  .nav-dropdown {
    width: 100%;
  }

  .nav-dropdown-toggle {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    justify-content: space-between;
  }

  .nav-dropdown-toggle i:last-child {
    font-size: 12px;
  }

  .nav-dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    background: rgba(255,255,255,0.05);
    border-radius: var(--radius-sm);
    margin-top: 2px;
    margin-bottom: 4px;
    padding: 4px;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    display: none;
  }

  .nav-dropdown--open .nav-dropdown-menu {
    display: block;
  }

  .nav-dropdown-menu a {
    color: var(--gray-300);
    padding: 10px 16px 10px 28px;
  }

  .nav-dropdown-menu a:hover {
    background: rgba(255,255,255,0.08);
    color: white;
  }

  .nav-dropdown-menu a.active {
    background: var(--primary);
    color: white;
  }

  .nav-dropdown-menu a i {
    color: var(--gray-500);
  }

  .nav-dropdown-menu a:hover i {
    color: white;
  }

  .mobile-menu-btn {
    display: block;
  }

  .mobile-nav-overlay {
    display: block;
  }

  .mobile-user-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 0 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: 12px;
  }

  .mobile-user-section .user-info {
    color: white;
  }

  .mobile-user-section .logout-btn {
    color: var(--gray-400);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
  }

  .mobile-user-section .logout-btn:hover {
    color: var(--danger);
    background: rgba(239,68,68,0.1);
  }

  .top-navbar-user {
    display: none;
  }

  .page-title-bar {
    padding: 12px 16px;
    top: 52px;
  }

  .top-bar-date {
    display: none;
  }

  .content-wrapper {
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .stat-card {
    padding: 16px;
  }

  .stat-info h4 {
    font-size: 22px;
  }

  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
  }

  .filter-bar .form-control {
    width: 100%;
    min-width: 0;
  }

  .filter-bar .btn {
    margin-left: 0;
  }

  .detail-header {
    flex-direction: column;
    padding: 16px;
  }

  .detail-avatar {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }

  .detail-actions {
    margin-left: 0;
    width: 100%;
    flex-wrap: wrap;
  }

  .detail-meta {
    gap: 10px;
  }

  .alert {
    margin: 0 16px;
  }

  .attendance-grid,
  .grade-grid {
    grid-template-columns: 1fr;
  }

  .card-header {
    padding: 16px;
    flex-direction: column;
    align-items: flex-start;
  }

  .card-body {
    padding: 16px;
  }

  .info-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .empty-state {
    padding: 32px 16px;
  }

  .empty-state i {
    font-size: 36px;
  }

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

  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    padding: 12px 16px;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .action-buttons {
    flex-wrap: wrap;
  }

  .search-box input {
    padding-left: 36px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-info h4 {
    font-size: 20px;
  }

  .login-container {
    margin: 16px;
    padding: 20px;
    max-width: calc(100% - 32px);
  }

  .login-logo {
    font-size: 36px;
  }

  .login-header h1 {
    font-size: 20px;
  }

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

  .detail-info h2 {
    font-size: 18px;
  }

  /* Better table scrolling on small screens */
  .table-container {
    margin: 0 -16px;
    padding: 0 16px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    position: relative;
  }

  .table-container::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(to right, transparent, rgba(79, 70, 229, 0.06));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
  }

  .table-container.is-scrollable::after {
    opacity: 1;
  }

  .table-container table {
    min-width: 550px;
  }

  .table-container table tbody td {
    font-size: 13px;
    padding: 10px 10px;
  }

  .table-container table thead th {
    font-size: 11px;
    padding: 10px 10px;
    position: sticky;
    top: 0;
    z-index: 1;
  }

  .table-container .truncate {
    max-width: 100px;
  }

  .btn {
    min-height: 44px;
  }

  .btn-sm {
    min-height: 36px;
  }

  .btn-lg {
    min-height: 48px;
  }

  .form-control {
    padding: 12px 14px;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  select.form-control {
    padding: 12px 36px 12px 14px;
    font-size: 16px;
  }

  .content-wrapper {
    padding: 12px;
  }

  .page-title-bar {
    padding: 10px 16px;
  }

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

  .d-flex.gap-4 {
    gap: 10px;
  }

  .widget-body {
    padding: 12px 16px;
  }

  .widget-header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .grade-item {
    flex-wrap: wrap;
    padding: 10px;
  }

  .grade-item input {
    width: 70px;
  }

  .attendance-item {
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  .attendance-status {
    flex-wrap: wrap;
  }

  .status-btn {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 12px;
  }

  /* Card improvements */
  .card-header {
    padding: 14px 16px;
  }
  .card-body {
    padding: 14px 16px;
  }
  .card-footer {
    padding: 12px 16px;
  }

  /* Modal improvements */
  [id$="Modal"] > .card {
    margin: 8px !important;
    max-height: calc(100vh - 16px) !important;
    overflow-y: auto;
  }

  /* Filter bar */
  .filter-bar {
    padding: 12px;
    gap: 10px;
  }

  .filter-bar .btn {
    flex: 1;
    justify-content: center;
  }

  /* Action buttons group */
  .action-buttons {
    gap: 3px;
  }

  /* Detail header */
  .detail-header {
    padding: 14px;
  }

  /* Empty state */
  .empty-state {
    padding: 28px 16px;
  }
  .empty-state i {
    font-size: 32px;
  }
  .empty-state h3 {
    font-size: 16px;
  }

  /* Alert messages */
  .alert {
    padding: 10px 14px;
    font-size: 13px;
    margin: 0 12px;
  }

  /* Table hint - fade indicator on scrollable tables */
  table thead th:last-child,
  table tbody td:last-child {
    position: sticky;
    right: 0;
    background: inherit;
  }

  table thead th:last-child::after,
  table tbody td:last-child::after {
    content: '';
    position: absolute;
    left: -20px;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(to right, transparent, white);
    pointer-events: none;
  }

  /* Badges more compact */
  .badge {
    font-size: 11px;
    padding: 2px 8px;
  }

  /* Progress bar compact */
  .progress-bar {
    height: 6px;
  }
}

@media (max-width: 360px) {
  .content-wrapper {
    padding: 8px;
  }

  .stats-grid {
    gap: 8px;
  }

  .login-container {
    padding: 14px;
    margin: 8px;
    max-width: calc(100% - 16px);
  }

  .login-header {
    margin-bottom: 20px;
  }

  .login-header h1 {
    font-size: 18px;
  }

  .table-container table tbody td {
    font-size: 12px;
    padding: 8px;
  }

  .table-container table thead th {
    font-size: 10px;
    padding: 8px;
  }

  .table-container table {
    min-width: 480px;
  }

  .stat-card {
    padding: 12px;
    gap: 12px;
  }

  .stat-icon {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .stat-info h4 {
    font-size: 18px;
  }

  .stat-info p {
    font-size: 12px;
  }

  .card-header h3 {
    font-size: 14px;
  }

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

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

  .page-title-bar {
    padding: 8px 12px;
  }

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

  .filter-bar {
    padding: 10px;
  }
}

/* ===== Modal Overlay ===== */
[id$="Modal"] {
  animation: modalFadeIn 0.2s ease-out;
}

/* Smooth card entrance inside modals — the overlay fades in first, then the
   card slides up with a gentle spring-like easing. The !important overrides
   the base .card animation (cardEntrance) which has opacity: 0. */
[id$="Modal"] > .card {
  animation: modalSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) 0.05s forwards !important;
  opacity: 1 !important;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ===== Audit Detail Modal ===== */
.audit-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 999;
  pointer-events: none;
  animation: auditOverlayFadeIn 0.2s ease forwards;
}

@keyframes auditOverlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.audit-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.audit-modal--open {
  pointer-events: auto;
}

.audit-modal-content {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 580px;
  max-height: 80vh;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(20px) scale(0.97);
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

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

.audit-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
}

.audit-modal-header h4 {
  font-size: 17px;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.audit-modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: #9ca3af;
  padding: 0;
  line-height: 1;
  transition: all 0.15s ease;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.audit-modal-close:hover {
  color: #111827;
  background: #f3f4f6;
}

.audit-modal-body {
  padding: 20px 24px;
}

.audit-section {
  margin-bottom: 16px;
}

.audit-section:last-child {
  margin-bottom: 0;
}

.audit-section-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  padding: 6px 12px;
  border-radius: 6px;
  display: inline-block;
}

.audit-section-title--old {
  color: #991b1b;
  background: #fee2e2;
}

.audit-section-title--new {
  color: #065f46;
  background: #d1fae5;
}

.audit-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

.audit-detail-label {
  padding: 6px 12px 6px 0;
  font-weight: 600;
  color: #6b7280;
  white-space: nowrap;
  width: 40%;
  vertical-align: top;
  border-bottom: 1px solid #f3f4f6;
}

.audit-detail-value {
  padding: 6px 0;
  color: #1f2937;
  border-bottom: 1px solid #f3f4f6;
  word-break: break-word;
}

.audit-modal-footer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #e5e7eb;
  font-size: 12px;
  color: #9ca3af;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.audit-modal-footer strong {
  color: #6b7280;
}

/* ===== Modal Responsive ===== */
@media (max-width: 768px) {
  [id$="Modal"] > div {
    width: 95% !important;
    max-width: 95% !important;
    margin: 10px auto;
    max-height: 85vh;
    overflow-y: auto;
  }

  [id$="Modal"] .modal-content {
    padding: 20px !important;
  }

  [id$="Modal"] .form-row {
    grid-template-columns: 1fr;
  }

  [id$="Modal"] .form-actions {
    flex-direction: column;
  }

  [id$="Modal"] .form-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ===== View Toggle ===== */
.view-toggle {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.view-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.view-toggle-btn:hover {
  color: var(--gray-700);
}

.view-toggle-btn.active {
  background: white;
  color: var(--gray-800);
  box-shadow: var(--shadow-sm);
}

.view-toggle-btn i {
  font-size: 14px;
}

@media (max-width: 768px) {
  .view-toggle {
    width: 100%;
  }

  .view-toggle-btn {
    flex: 1;
    justify-content: center;
    padding: 10px 8px;
    font-size: 12px;
  }

  .view-toggle-btn i {
    font-size: 13px;
  }
}

/* ===== Year Section (vista agrupada por año) ===== */
.year-section {
  margin-bottom: 20px;
}

.year-section:last-child {
  margin-bottom: 0;
}

.year-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  margin-bottom: 12px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}

.year-section-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 700;
  background: var(--primary);
  color: white;
  letter-spacing: 0.3px;
}

.year-section-count {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-400);
  margin-left: auto;
}

.year-subject-group {
  margin-bottom: 12px;
}

.year-subject-group:last-child {
  margin-bottom: 0;
}

.year-subject-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  margin-left: 20px;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--gray-400);
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--gray-200);
}

.year-subject-empty i {
  font-size: 16px;
  color: #d1fae5;
}

/* Staggered entrance for year sections */
@keyframes yearSectionEntrance {
  0% {
    opacity: 0;
    transform: translateY(16px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.year-section {
  animation: yearSectionEntrance 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.year-section:nth-child(1) { animation-delay: 0.02s; }
.year-section:nth-child(2) { animation-delay: 0.08s; }
.year-section:nth-child(3) { animation-delay: 0.14s; }
.year-section:nth-child(4) { animation-delay: 0.20s; }
.year-section:nth-child(5) { animation-delay: 0.26s; }
.year-section:nth-child(6) { animation-delay: 0.32s; }

@media (max-width: 768px) {
  .year-section-header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .year-section-count {
    margin-left: 0;
    width: 100%;
  }

  .year-subject-empty {
    margin-left: 12px;
    padding: 10px 14px;
    font-size: 13px;
  }
}

/* ===== Prerequisite Selector UI ===== */
.prereq-subject-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px 20px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow 0.25s ease;
}

.prereq-subject-header:hover {
  box-shadow: var(--shadow-md);
}

.prereq-subject-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 10px;
}

.prereq-year-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  background: var(--primary);
  color: white;
  letter-spacing: 0.3px;
}

.prereq-count {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-400);
  white-space: nowrap;
}

.prereq-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.prereq-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

.prereq-card:hover {
  border-color: var(--gray-300);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.prereq-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-100);
  background: var(--gray-50);
}

.prereq-type-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  margin-left: 4px;
}

.prereq-card-body {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.prereq-conditions {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.prereq-condition-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.prereq-condition-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.prereq-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

#prereqResults {
  transition: opacity 0.2s ease;
}

#prereqResults.prereq-results--loading {
  opacity: 0;
}

.prereq-card .badge + .badge {
  margin-left: 0;
}

@keyframes prereqCardEntrance {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.prereq-list .prereq-card {
  animation: prereqCardEntrance 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.prereq-list .prereq-card:nth-child(1) { animation-delay: 0.02s; }
.prereq-list .prereq-card:nth-child(2) { animation-delay: 0.06s; }
.prereq-list .prereq-card:nth-child(3) { animation-delay: 0.10s; }
.prereq-list .prereq-card:nth-child(4) { animation-delay: 0.14s; }
.prereq-list .prereq-card:nth-child(5) { animation-delay: 0.18s; }
.prereq-list .prereq-card:nth-child(6) { animation-delay: 0.22s; }
.prereq-list .prereq-card:nth-child(7) { animation-delay: 0.26s; }
.prereq-list .prereq-card:nth-child(8) { animation-delay: 0.30s; }
.prereq-list .prereq-card:nth-child(9) { animation-delay: 0.34s; }
.prereq-list .prereq-card:nth-child(10) { animation-delay: 0.38s; }

@media (max-width: 768px) {
  .prereq-subject-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 16px;
  }

  .prereq-subject-header h3 {
    font-size: 14px;
  }

  .prereq-card-body {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .prereq-conditions {
    width: 100%;
    gap: 16px;
  }

  .prereq-actions {
    width: 100%;
    border-top: 1px solid var(--gray-100);
    padding-top: 12px;
    justify-content: flex-end;
  }

  .prereq-card-header {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .prereq-card-body {
    padding: 12px 16px;
  }

  .prereq-type-label {
    font-size: 13px;
  }
}

/* ===== Prerequisite Admin Styles (legacy) ===== */
.prereq-mode-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--gray-100);
  color: var(--gray-600);
}

.prereq-description {
  max-width: 250px;
  white-space: normal;
  word-wrap: break-word;
}

[id$="Modal"] .form-row {
  gap: 12px;
}

/* ===== Utility Classes ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.fw-bold { font-weight: 600; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.d-flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Entrance Animations ===== */
@keyframes cardEntrance {
  0% {
    opacity: 0;
    transform: translateY(40px) scale(0.90);
  }
  50% {
    opacity: 0.8;
    transform: translateY(-4px) scale(1.01);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes iconPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  60% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes slideInItem {
  0% {
    opacity: 0;
    transform: translateX(-12px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes progressFill {
  0% {
    transform: scaleX(0);
  }
  100% {
    transform: scaleX(1);
  }
}

.card {
  animation: cardEntrance 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  opacity: 0;
}

.dashboard-grid .widget {
  animation: cardEntrance 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  opacity: 0;
}

.dashboard-grid .widget:nth-child(1) { animation-delay: 0.45s; }
.dashboard-grid .widget:nth-child(2) { animation-delay: 0.55s; }

.dashboard-grid .widget .progress-bar-fill {
  animation: progressFill 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  transform-origin: left;
  transform: scaleX(0);
}

.dashboard-grid .widget:nth-child(1) .progress-bar-fill { animation-delay: 0.7s; }
.dashboard-grid .widget:nth-child(2) .progress-bar-fill { animation-delay: 0.8s; }

.dashboard-grid .widget .widget-list li {
  animation: slideInItem 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  opacity: 0;
  transform: translateX(-12px);
}

.dashboard-grid .widget:nth-child(1) .widget-list li:nth-child(1) { animation-delay: 0.65s; }
.dashboard-grid .widget:nth-child(1) .widget-list li:nth-child(2) { animation-delay: 0.72s; }
.dashboard-grid .widget:nth-child(1) .widget-list li:nth-child(3) { animation-delay: 0.79s; }
.dashboard-grid .widget:nth-child(1) .widget-list li:nth-child(4) { animation-delay: 0.86s; }
.dashboard-grid .widget:nth-child(1) .widget-list li:nth-child(5) { animation-delay: 0.93s; }

.dashboard-grid .widget:nth-child(2) .widget-list li:nth-child(1) { animation-delay: 0.75s; }
.dashboard-grid .widget:nth-child(2) .widget-list li:nth-child(2) { animation-delay: 0.82s; }
.dashboard-grid .widget:nth-child(2) .widget-list li:nth-child(3) { animation-delay: 0.89s; }
.dashboard-grid .widget:nth-child(2) .widget-list li:nth-child(4) { animation-delay: 0.96s; }
.dashboard-grid .widget:nth-child(2) .widget-list li:nth-child(5) { animation-delay: 1.03s; }

.stats-grid .stat-card {
  animation: cardEntrance 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  opacity: 0;
}

.stats-grid .stat-card:nth-child(1) { animation-delay: 0.05s; }
.stats-grid .stat-card:nth-child(2) { animation-delay: 0.15s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 0.25s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 0.35s; }

.stats-grid .stat-card .stat-icon i {
  animation: iconPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  opacity: 0;
}

.stats-grid .stat-card:nth-child(1) .stat-icon i { animation-delay: 0.25s; }
.stats-grid .stat-card:nth-child(2) .stat-icon i { animation-delay: 0.35s; }
.stats-grid .stat-card:nth-child(3) .stat-icon i { animation-delay: 0.45s; }
.stats-grid .stat-card:nth-child(4) .stat-icon i { animation-delay: 0.55s; }
