/* cal.css - Estilos UX/UI de la Aplicación Cal+ */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border-color: #e2e8f0;
  --header-bg: #ffffff;
  --drawer-bg: #ffffff;
  
  --success-color: #16a34a;
  --success-bg: #dcfce7;
  --danger-color: #dc2626;
  --danger-bg: #fee2e2;
  --warning-color: #d97706;
  --warning-bg: #fef3c7;
  --purple-color: #9333ea;
  --purple-bg: #f3e8ff;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --primary-color: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e293b;
  --bg-color: #0f172a;
  --card-bg: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --border-color: #334155;
  --header-bg: #1e293b;
  --drawer-bg: #1e293b;
  
  --success-color: #22c55e;
  --success-bg: #14532d;
  --danger-color: #ef4444;
  --danger-bg: #7f1d1d;
  --warning-color: #f59e0b;
  --warning-bg: #78350f;
  --purple-color: #c084fc;
  --purple-bg: #581c87;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  overscroll-behavior: none !important;
  overscroll-behavior-y: none !important;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 74px; /* Espacio para barra inferior móvil */
  transition: background-color 0.2s, color 0.2s;
}

main, .tab-content, .drawer, .modal-card, #historial-con-list, #logros-table-container, #notas-accordion, #diag-tables-grid {
  overscroll-behavior-y: contain;
}

/* Encabezado Superior */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
  color: white;
  font-weight: 900;
  font-size: 1.15rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 4px;
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1.1rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--card-bg);
  transition: all 0.2s;
}

.btn-icon:hover {
  background-color: var(--primary-light);
  border-color: var(--primary-color);
}

/* Switch Horario de Emergencia */
.schedule-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-color);
  padding: 4px 8px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.schedule-switch.emergency {
  background: var(--danger-bg);
  color: var(--danger-color);
  border-color: var(--danger-color);
}

/* Contenedor Principal */
.main-container {
  flex: 1;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  padding: 14px 12px;
}

/* Barra de Navegación Inferior Móvil */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background-color: var(--header-bg);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.nav-tab {
  flex: 1;
  height: 100%;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s;
}

.nav-tab.active {
  color: var(--primary-color);
}

.nav-tab-icon {
  font-size: 1.35rem;
}

/* Pestañas / Vistas */
.tab-content {
  display: none;
  animation: fadeIn 0.15s ease-out;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Tarjetas Principales */
.card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Barra Informativa de Clase en Vivo */
.live-class-banner {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(139, 92, 246, 0.1));
  border: 1px solid var(--primary-color);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.live-class-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.live-class-tag {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--primary-color);
  letter-spacing: 0.5px;
}

.live-class-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
}

.live-class-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Filtros y Selectores en Fila */
.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.form-control {
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--primary-color);
}

/* Banner de Volados y WhatsApp */
.volados-alert {
  background-color: var(--purple-bg);
  border: 1px solid var(--purple-color);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.volados-text {
  font-size: 0.82rem;
  color: var(--text-primary);
  line-height: 1.3;
}

.btn-whatsapp {
  background-color: #25d366;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
}

.btn-whatsapp:hover {
  background-color: #1eb956;
}

/* Lista de Estudiantes en Asistencia */
.student-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.student-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.student-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.student-card.att-card-intermitente {
  border-left: 5px solid #f59e0b !important;
  background-color: rgba(245, 158, 11, 0.05);
}

.student-card.att-card-nunca {
  border-left: 5px solid #dc2626 !important;
  background-color: rgba(220, 38, 38, 0.06);
}

.student-index {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-muted);
  min-width: 22px;
}

.student-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

.student-name.att-intermitente {
  color: #d97706 !important;
  font-weight: 800;
}

[data-theme="dark"] .student-name.att-intermitente {
  color: #fbbf24 !important;
}

.student-name.att-nunca {
  color: #dc2626 !important;
  font-weight: 800;
}

[data-theme="dark"] .student-name.att-nunca {
  color: #f87171 !important;
}

.student-att-badge {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 800;
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  vertical-align: middle;
}

.student-att-badge.badge-intermitente {
  background-color: var(--warning-bg);
  color: var(--warning-color);
  border: 1px solid rgba(217, 119, 6, 0.3);
}

.student-att-badge.badge-nunca {
  background-color: var(--danger-bg);
  color: var(--danger-color);
  border: 1px solid rgba(220, 38, 38, 0.3);
}

.student-badge-dis {
  font-size: 0.68rem;
  background: var(--warning-bg);
  color: var(--warning-color);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

/* Botones de Asistencia */
.attendance-actions {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.btn-att {
  border: 1px solid var(--border-color);
  background-color: var(--bg-color);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 8px 2px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all 0.15s;
}

.btn-att-icon {
  font-size: 1rem;
}

.btn-att.active-asistio {
  background-color: var(--success-bg);
  color: var(--success-color);
  border-color: var(--success-color);
}

.btn-att.active-no_asistio {
  background-color: var(--danger-bg);
  color: var(--danger-color);
  border-color: var(--danger-color);
}

.btn-att.active-excusa {
  background-color: var(--warning-bg);
  color: var(--warning-color);
  border-color: var(--warning-color);
}

.btn-att.active-volado {
  background-color: var(--purple-bg);
  color: var(--purple-color);
  border-color: var(--purple-color);
}

.btn-att.active-retirado {
  background-color: #e2e8f0;
  color: #475569;
  border-color: #64748b;
}

/* ================================================= */
/* SECCIÓN CALIFICAR: LISTADO TÁCTIL Y PANEL FLOTANTE */
/* ================================================= */

.cal-student-list-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 120px; /* Espacio para no tapar con panel flotante */
}

.cal-student-row {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.cal-student-row:hover {
  background-color: var(--primary-light);
  border-color: var(--primary-color);
}

.cal-student-row.selected {
  background-color: var(--primary-light);
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--primary-color);
}

.cal-student-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.cal-student-num {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-muted);
  min-width: 24px;
}

.cal-student-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.chip-status {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.chip-status.chip-graded {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

[data-theme="dark"] .chip-status.chip-graded {
  background-color: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.4);
}

.chip-status.chip-pending {
  background-color: var(--border-color);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

/* Barra Inferior Ergonómica de Búsqueda y Escáner (Zona de Pulgar) */
.cal-bottom-search-bar {
  position: fixed;
  bottom: 60px; /* Justo sobre el bottom-nav */
  left: 0;
  right: 0;
  max-width: 100%;
  margin: 0;
  background-color: var(--card-bg);
  border-top: 1px solid var(--border-color);
  padding: 8px 10px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.1);
  z-index: 90;
  display: flex;
  flex-direction: column;
}

.cal-search-suggestions {
  position: absolute;
  bottom: 100%;
  left: 10px;
  right: 10px;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius) var(--radius) 0 0;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.2);
  z-index: 91;
  display: flex;
  flex-direction: column;
}

.cal-suggestion-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.15s;
}

.cal-suggestion-item:last-child {
  border-bottom: none;
}

.cal-suggestion-item:hover,
.cal-suggestion-item:active {
  background-color: var(--primary-light);
}

.cal-suggestion-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-suggestion-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.cal-suggestion-sub {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.cal-suggestion-badge {
  font-size: 0.74rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-color);
  color: var(--primary-color);
  border: 1px solid var(--border-color);
}

/* Panel Inferior Flotante de Calificación */
.cal-grading-panel {
  position: fixed;
  bottom: 60px; /* Justo arriba del bottom-nav */
  left: 0;
  right: 0;
  max-width: 900px;
  margin: 0 auto;
  background-color: var(--card-bg);
  border-top: 3px solid var(--primary-color);
  border-radius: 16px 16px 0 0;
  padding: 12px 14px 16px 14px;
  box-shadow: 0 -10px 30px rgba(0,0,0,0.25);
  z-index: 95;
  animation: slideUpPanel 0.2s ease-out;
}

@keyframes slideUpPanel {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.cal-grading-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4px;
}

.cal-badge-target {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--primary-color);
}

.cal-selected-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.cal-selected-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.grade-display-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 4px;
}

.btn-step-grade {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: all 0.1s;
}

.btn-step-grade:active {
  transform: scale(0.92);
  background-color: var(--primary-light);
  border-color: var(--primary-color);
}

.grade-slider-box {
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}

.grade-big-display {
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--primary-color);
  line-height: 1;
}

.grade-range-input {
  width: 100%;
  height: 12px;
  border-radius: 6px;
  background: var(--border-color);
  outline: none;
  cursor: pointer;
  margin: 10px 0;
}

.grade-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 4px;
}

.quick-grade-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
}

.chip-grade {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 3px 8px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
}

.chip-grade:hover {
  background: var(--primary-light);
  border-color: var(--primary-color);
}

/* Botones Principales */
.btn-primary {
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  transition: background-color 0.2s;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* Escáner de Cámara */
.scanner-container {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.btn-scanner {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  min-width: 46px;
  flex-shrink: 0;
  transition: transform 0.1s, opacity 0.2s;
}

.btn-scanner:active {
  transform: scale(0.94);
}

/* Modales */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0,0,0,0.6);
  backdrop-filter: blur(3px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 800;
}

/* Drawer / Menú Lateral */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0,0,0,0.5);
  z-index: 1000;
  display: none;
}

.drawer-overlay.active {
  display: block;
}

.drawer {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  height: 100%;
  background-color: var(--drawer-bg);
  border-left: 1px solid var(--border-color);
  z-index: 1001;
  transition: right 0.25s ease-out;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
}

.drawer.active {
  right: 0;
}

.drawer-title {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  text-align: left;
  width: 100%;
}

.drawer-menu-item:hover {
  background-color: var(--primary-light);
  border-color: var(--border-color);
}

/* Tablas Crudas del Sistema */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  max-height: 400px;
}

.raw-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.raw-table th, .raw-table td {
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  text-align: left;
  white-space: nowrap;
}

.raw-table th {
  background-color: var(--bg-color);
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Encabezados Ordenables y Flechas de Clasificación */
.sortable-th {
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.sortable-th:hover {
  background-color: var(--primary-light, rgba(37, 99, 235, 0.08)) !important;
  color: var(--primary-color) !important;
}

.sortable-th .th-content {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: inherit;
  width: 100%;
}

.table-sort-arrow {
  font-size: 0.72rem;
  display: inline-block;
  opacity: 0.35;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.table-sort-arrow.active {
  opacity: 1;
  color: var(--primary-color, #2563eb);
  font-weight: 800;
}

.sortable-th:hover .table-sort-arrow.neutral {
  opacity: 0.75;
}

/* Toast */
.toast-msg {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #0f172a;
  color: white;
  padding: 9px 18px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  display: none;
  animation: toastIn 0.2s ease-out;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ====================================== */
/* Cal+ v2.0 - Cronograma Diario          */
/* ====================================== */
.cronograma-container {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0;
  -webkit-overflow-scrolling: touch;
}

.cronograma-card {
  flex: 0 0 auto;
  min-width: 110px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-color);
  background: var(--card-bg);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.cronograma-card:hover {
  border-color: var(--primary-color);
  transform: translateY(-1px);
}

.cronograma-card.active {
  border-color: var(--primary-color);
  background: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.cronograma-card.taken {
  border-color: var(--success-color);
  background: var(--success-bg);
}

.cronograma-hora {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--primary-color);
  text-transform: uppercase;
}

.cronograma-grupo {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 2px 0;
}

.cronograma-asig {
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cronograma-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-top: 3px;
}

.cronograma-badge.pending {
  background: var(--warning-bg);
  color: var(--warning-color);
}

.cronograma-badge.done {
  background: var(--success-bg);
  color: var(--success-color);
}

/* ====================================== */
/* Cal+ v2.0 - Notas Jerárquicas          */
/* ====================================== */
.notas-accordion {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notas-asig-group {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--card-bg);
}

.notas-asig-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--primary-light);
  cursor: pointer;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--primary-color);
  border-bottom: 1px solid var(--border-color);
  user-select: none;
}

.notas-asig-header:hover {
  background: var(--primary-color);
  color: white;
}

.notas-asig-header .toggle-icon {
  transition: transform 0.2s;
}

.notas-asig-header.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.notas-grupo-group {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-color);
}

.notas-grupo-group:last-child {
  border-bottom: none;
}

.notas-grupo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  user-select: none;
}

.notas-grupo-header:hover {
  background: var(--bg-color);
}

.notas-actividad-item {
  margin: 4px 0 4px 12px;
  padding: 6px 8px;
  border-left: 3px solid var(--primary-color);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--bg-color);
}

.notas-actividad-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
  cursor: pointer;
  user-select: none;
}

.notas-actividad-title:hover {
  color: var(--primary-color);
}

.notas-student-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 6px;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border-color);
}

.notas-student-row:last-child {
  border-bottom: none;
}

.notas-student-name {
  flex: 1;
  color: var(--text-primary);
}

.notas-student-nota {
  font-weight: 800;
  color: var(--primary-color);
  min-width: 40px;
  text-align: right;
}

/* ====================================== */
/* Cal+ v2.0 - Historial Asistencias      */
/* ====================================== */
.historial-con-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--card-bg);
  cursor: pointer;
  transition: border-color 0.2s;
}

.historial-con-card:hover {
  border-color: var(--primary-color);
}

.historial-con-card.expanded {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.historial-con-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.historial-con-header .con-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.historial-con-header .con-fecha {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.historial-con-header .con-detail {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.historial-con-header .con-badges {
  display: flex;
  gap: 6px;
  align-items: center;
}

.historial-con-header .badge-count {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.badge-count.asistieron {
  background: var(--success-bg);
  color: var(--success-color);
}

.badge-count.faltaron {
  background: var(--danger-bg);
  color: var(--danger-color);
}

.badge-count.volados {
  background: var(--purple-bg);
  color: var(--purple-color);
}

.historial-asi-list {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
  display: none;
}

.historial-con-card.expanded .historial-asi-list {
  display: block;
}

.historial-asi-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 4px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.82rem;
}

.historial-asi-row:last-child {
  border-bottom: none;
}

.historial-asi-row .asi-nombre {
  flex: 1;
  color: var(--text-primary);
  font-weight: 600;
}

.historial-asi-row .asi-actions {
  display: flex;
  gap: 4px;
}

.historial-asi-row .btn-estado {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  border: 1px solid var(--border-color);
  background: var(--bg-color);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.historial-asi-row .btn-estado.active-asistio {
  background: var(--success-bg);
  color: var(--success-color);
  border-color: var(--success-color);
}

.historial-asi-row .btn-estado.active-no_asistio {
  background: var(--danger-bg);
  color: var(--danger-color);
  border-color: var(--danger-color);
}

.historial-asi-row .btn-estado.active-excusa {
  background: var(--warning-bg);
  color: var(--warning-color);
  border-color: var(--warning-color);
}

.historial-asi-row .btn-estado.active-volado {
  background: var(--purple-bg);
  color: var(--purple-color);
  border-color: var(--purple-color);
}

/* ====================================== */
/* Cal+ v2.0 - CRUD Table Editor          */
/* ====================================== */
.table-edit-btn {
  padding: 2px 8px;
  font-size: 0.72rem;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: var(--bg-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.table-edit-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.crud-form-field {
  margin-bottom: 8px;
}

.crud-form-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 3px;
}

.crud-form-field input,
.crud-form-field select,
.crud-form-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: var(--font-main);
}

.crud-form-field input:focus,
.crud-form-field select:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.crud-form-field input[readonly] {
  background: var(--bg-color);
  color: var(--text-muted);
}

/* ====================================== */
/* Cal+ v2.0 - Login Screen               */
/* ====================================== */
.login-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  background: var(--bg-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.login-logo {
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--primary-color);
  letter-spacing: -2px;
}

.login-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  text-align: center;
  max-width: 300px;
}

.btn-google-login {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 28px;
  border: 2px solid var(--border-color);
  border-radius: 50px;
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 700;
  font-family: var(--font-main);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.btn-google-login:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-google-login img {
  width: 22px;
  height: 22px;
}

.login-footer {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* ==========================================================================
   BOTÓN Y MODAL DE SINCRONIZACIÓN EN LA NUBE & COLA OFFLINE
   ========================================================================== */
.header-sync-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.header-sync-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.header-sync-btn.online {
  background-color: var(--success-bg);
  color: var(--success-color);
  border-color: rgba(22, 163, 74, 0.3);
}

.header-sync-btn.syncing {
  background-color: var(--primary-light);
  color: var(--primary-color);
  border-color: rgba(37, 99, 235, 0.3);
}

.header-sync-btn.syncing .sync-icon {
  display: inline-block;
  animation: spin 1s linear infinite;
}

.header-sync-btn.pending {
  background-color: var(--warning-bg);
  color: var(--warning-color);
  border-color: rgba(217, 119, 6, 0.3);
}

.header-sync-btn.offline {
  background-color: var(--bg-secondary, #e2e8f0);
  color: var(--text-muted);
  border-color: var(--border-color);
}

.header-sync-btn.noauth {
  background-color: var(--warning-bg);
  color: var(--warning-color);
  border-color: rgba(217, 119, 6, 0.3);
}

.sync-status-tag.noauth {
  background-color: var(--warning-bg);
  color: var(--warning-color);
}

.header-sync-btn.error {
  background-color: var(--danger-bg);
  color: var(--danger-color);
  border-color: rgba(220, 38, 38, 0.3);
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: #ef4444;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  margin-left: 2px;
}

.sync-status-tag {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
  text-transform: uppercase;
}

.sync-status-tag.online {
  background: var(--success-bg);
  color: var(--success-color);
}

.sync-status-tag.syncing {
  background: var(--primary-light);
  color: var(--primary-color);
}

.sync-status-tag.pending, .sync-status-tag.offline {
  background: var(--warning-bg);
  color: var(--warning-color);
}

.sync-status-tag.error {
  background: var(--danger-bg);
  color: var(--danger-color);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   OVERLAY DE CARGA CON BARRA DE PROGRESO EN VIVO
   ========================================================================== */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.loading-logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.loading-logo {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--primary-color), var(--purple-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.loading-badge {
  font-size: 0.72rem;
  font-weight: 800;
  background: var(--primary-light);
  color: var(--primary-color);
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.loading-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.loading-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 22px;
}

.progress-bar-container {
  width: 100%;
  height: 10px;
  background: var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), #8b5cf6);
  border-radius: 10px;
  transition: width 0.25s ease;
}

.loading-status-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.loading-status-sub {
  width: 100%;
  font-size: 0.76rem;
  color: var(--text-secondary);
  text-align: left;
  min-height: 20px;
  word-break: break-word;
}

/* ==========================================================================
   ESTILOS DE DIAGNÓSTICO
   ========================================================================== */
.diag-grid-item {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
}

.diag-table-name {
  font-family: monospace;
  font-weight: 800;
  color: var(--primary-color);
}

.diag-table-count {
  font-weight: 700;
  color: var(--text-secondary);
}

.diag-table-count.has-data {
  color: var(--success-color);
}

.diag-table-count.empty {
  color: var(--text-muted);
}

/* ==========================================================================
   ESTILOS DE JERARQUÍA DE CALIFICACIONES GUARDADAS (Calificar v2.1.1)
   ========================================================================== */
.cal-tree-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cal-grupo-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.cal-grupo-head {
  background: var(--bg-secondary);
  padding: 10px 14px;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--primary-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  user-select: none;
}

.cal-asig-block {
  border-bottom: 1px solid var(--border-color);
}
.cal-asig-block:last-child {
  border-bottom: none;
}

.cal-asig-head {
  padding: 9px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  background: rgba(37, 99, 235, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  user-select: none;
}

.cal-act-block {
  border-bottom: 1px solid var(--border-color);
}
.cal-act-block:last-child {
  border-bottom: none;
}

.cal-act-head {
  padding: 9px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  background: var(--card-bg);
  user-select: none;
}
.cal-act-head:hover {
  background: var(--bg-secondary);
}

.cal-act-notas-list {
  padding: 6px 12px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-primary);
}

.cal-grade-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.cal-grade-item-row:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}

.cal-grade-student-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-primary);
}

.cal-grade-student-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.cal-grade-badge {
  font-size: 0.88rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cal-grade-badge.good {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}
.cal-grade-badge.low {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

.cal-edit-pill-btn {
  font-size: 0.76rem;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--primary-color);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* Botón Acción Rápida + Participación */
.btn-quick-part {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
  transition: transform 0.1s ease, filter 0.2s ease, box-shadow 0.2s ease;
}

.btn-quick-part:hover {
  filter: brightness(1.05);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.45);
}

.btn-quick-part:active {
  transform: scale(0.98);
  filter: brightness(0.95);
}
/* Banner Informativo de Periodo y Calendario Escolar (Vista Calificar) */
.cal-periodo-banner {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  border-radius: var(--radius-sm, 8px);
  padding: 8px 12px;
  margin-bottom: 6px;
  color: #78350f;
  font-size: 0.78rem;
  box-shadow: 0 1px 4px rgba(245, 158, 11, 0.18);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

[data-theme="dark"] .cal-periodo-banner {
  background: linear-gradient(135deg, rgba(120, 53, 15, 0.45) 0%, rgba(180, 83, 9, 0.3) 100%);
  border-color: rgba(245, 158, 11, 0.55);
  color: #fef08a;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

.cal-periodo-banner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
  font-weight: 800;
  font-size: 0.83rem;
  color: #92400e;
}

[data-theme="dark"] .cal-periodo-banner-header {
  color: #fbbf24;
}

.cal-periodo-banner-details {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 0.76rem;
  color: #78350f;
}

[data-theme="dark"] .cal-periodo-banner-details {
  color: #fde68a;
}

.cal-periodo-banner-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cal-periodo-banner-badge {
  background: #f59e0b;
  color: #ffffff;
  padding: 1px 7px;
  border-radius: 4px;
  font-weight: 800;
  font-size: 0.68rem;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

[data-theme="dark"] .cal-periodo-banner-badge {
  background: #d97706;
  color: #fffbeb;
}
