* { box-sizing: border-box; }

/* Variables de color para soportar modo oscuro */
:root {
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --card-bg-alt: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-strong: #1e3a8a;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --header-grad-1: #1e3a8a;
  --header-grad-2: #0ea5e9;
  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --soft-bg: #f1f5f9;
  --hover-bg: #f0f9ff;
  --table-header-bg: #f1f5f9;
  --input-bg: #ffffff;
  --modal-bg: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
}
html[data-theme="dark"] {
  --bg: #0b1220;
  --card-bg: #131b2e;
  --card-bg-alt: #0f172a;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-strong: #93c5fd;
  --border: #1e293b;
  --border-strong: #334155;
  --header-grad-1: #1e293b;
  --header-grad-2: #1e40af;
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --soft-bg: #0f172a;
  --hover-bg: #1e293b;
  --table-header-bg: #0f172a;
  --input-bg: #0f172a;
  --modal-bg: #131b2e;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
}

html, body {
  margin: 0; padding: 0;
  font-family: 'Roboto', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  transition: background 0.2s, color 0.2s;
}
body { padding: 16px; max-width: 800px; margin: 0 auto; }

/* Header con gradiente azul institucional */
.header {
  background: linear-gradient(135deg, #1e3a8a, #0ea5e9);
  color: white; padding: 18px 20px; border-radius: 12px; margin-bottom: 16px;
}
.header h1 { margin: 0; font-size: 22px; font-weight: 700; }
.header h2 { margin: 0; font-size: 18px; font-weight: 700; }
.header p { margin: 6px 0 0; font-size: 14px; opacity: 0.9; }
.header .bim {
  display: inline-block; background: rgba(255,255,255,0.2);
  padding: 3px 10px; border-radius: 14px; font-size: 12px; margin-top: 8px;
}
.header-row { display: flex; align-items: center; justify-content: space-between; }
.btn-logout {
  background: rgba(255,255,255,0.18); color: white; border: none;
  padding: 6px 12px; border-radius: 6px; font-size: 13px; cursor: pointer;
}
.btn-logout:hover { background: rgba(255,255,255,0.3); }

/* Cards */
.card {
  background: var(--card-bg); border-radius: 12px; padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  color: var(--text);
}
.card h3 {
  margin: 0 0 10px; font-size: 14px; font-weight: 700;
  color: var(--text-strong); text-transform: uppercase; letter-spacing: 0.5px;
}

/* Lista de aulas */
.aula {
  display: block; width: 100%; text-align: left; background: var(--soft-bg);
  border: 2px solid transparent; border-radius: 10px;
  padding: 14px 16px; margin-bottom: 8px; cursor: pointer;
  transition: all 0.15s; font-size: 16px; color: var(--text);
}
.aula:hover { border-color: var(--primary); background: var(--hover-bg); }
.aula .titulo { font-weight: 700; font-size: 17px; }
.aula .areas { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.aula .tutor-tag {
  display: inline-block; background: #fbbf24; color: #78350f;
  padding: 2px 8px; border-radius: 10px; font-size: 11px; margin-left: 8px; font-weight: 700;
}

/* Botones */
button { font-family: inherit; font-size: 16px; cursor: pointer; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: #0ea5e9; color: white; border: none;
  padding: 12px 20px; border-radius: 8px; font-weight: 700; font-size: 16px;
}
.btn-primary:hover:not(:disabled) { background: #0284c7; }
.btn-primary.full { width: 100%; }
.btn-secondary {
  background: var(--card-bg); color: var(--text-strong); border: 2px solid var(--text-strong);
  padding: 10px 16px; border-radius: 8px; font-weight: 600;
}
.btn-back { background: transparent; color: var(--text-muted); border: none; padding: 6px 10px; cursor: pointer; font-size: 14px; }
.btn-back:hover { color: var(--text); }

/* Inputs */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; color: var(--text); }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; font-size: 16px; font-family: inherit;
  border: 2px solid var(--border-strong); border-radius: 8px;
  background: var(--input-bg); color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); }

/* Status */
.status { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; display: none; }
.status.ok { background: #dcfce7; color: #166534; display: block; }
.status.err { background: #fee2e2; color: #991b1b; display: block; }
.status.info { background: #dbeafe; color: #1e3a8a; display: block; }

.loader { text-align: center; color: var(--text-muted); padding: 30px; font-size: 14px; }
.loader::before { content: "⏳ "; font-size: 18px; }

/* Login específico */
.login-wrap { max-width: 420px; margin: 60px auto 0; }
.login-wrap .header { text-align: center; }

/* Pills de áreas */
.area-pill {
  display: inline-block; background: var(--card-bg); color: var(--text);
  border: 2px solid var(--border-strong);
  border-radius: 20px; padding: 8px 16px; margin: 0 6px 8px 0;
  cursor: pointer; font-size: 14px; user-select: none;
}
.area-pill:hover { border-color: var(--primary); }
.area-pill.active { background: var(--primary); color: white; border-color: var(--primary); }

/* Lista de alumnos */
.alumno {
  display: flex; align-items: center; padding: 12px;
  background: var(--soft-bg); border-radius: 8px; margin-bottom: 6px; cursor: pointer;
  border: 2px solid transparent; color: var(--text);
}
.alumno:hover { background: var(--hover-bg); border-color: var(--primary); }
.alumno .num {
  background: var(--header-grad-1); color: white; width: 28px; height: 28px;
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; margin-right: 12px; flex-shrink: 0;
}
.alumno .nombre { flex: 1; font-size: 15px; }
.alumno .estado { font-size: 12px; color: var(--text-muted); margin-left: 8px; }
.alumno .estado.completo { color: #16a34a; font-weight: 600; }

/* Botón "Libreta" al lado de cada alumno */
.alumno .btn-libreta {
  background: var(--card-bg); color: var(--text-strong);
  border: 1px solid var(--text-strong); border-radius: 6px;
  padding: 4px 10px; font-size: 12px; font-weight: 600;
  cursor: pointer; margin-left: 8px;
}
.alumno .btn-libreta:hover { background: var(--text-strong); color: white; }

/* Badge TEA (Aula Azul) */
.badge-tea {
  display: inline-block; background: #dbeafe; color: #1e3a8a;
  border: 1px solid #93c5fd; padding: 1px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 700; margin-left: 6px;
}
html[data-theme="dark"] .badge-tea {
  background: #1e3a8a; color: #dbeafe; border-color: #3b82f6;
}

/* Botones de acciones a nivel de aula (registro instrumentos, conclusiones) */
.btn-aula-accion {
  background: var(--card-bg); color: var(--text-strong); border: 1px solid var(--text-strong);
  border-radius: 6px; padding: 5px 11px; font-size: 12px; font-weight: 600;
  cursor: pointer; margin-left: 8px;
}
.btn-aula-accion:hover { background: var(--text-strong); color: white; }

/* Modal de conclusiones por bimestre */
.modal-conclusiones {
  position: fixed; inset: 0; background: rgba(15,23,42,0.55);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 100; padding: 20px; overflow-y: auto;
}
.modal-conclusiones.open { display: flex; }
.modal-conclusiones .modal-box {
  background: var(--modal-bg); color: var(--text); border-radius: 12px; padding: 20px;
  width: 100%; max-width: 760px; margin: 0 auto;
  box-shadow: var(--shadow-lg);
}
.modal-conclusiones h3.modal-titulo { margin: 0 0 6px; color: var(--text-strong); font-size: 17px; }
.modal-conclusiones .concl-row {
  margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.modal-conclusiones .concl-row:last-child { border-bottom: none; }
.modal-conclusiones .concl-nombre { font-weight: 600; font-size: 14px; margin-bottom: 4px; color: var(--text); }
.modal-conclusiones textarea {
  width: 100%; border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 8px 10px; font-family: inherit; font-size: 13px; resize: vertical;
  background: var(--input-bg); color: var(--text);
}
.modal-conclusiones textarea:focus { outline: none; border-color: var(--primary); }
.modal-conclusiones .modal-acciones {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px;
  padding-top: 12px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--modal-bg);
}

/* Wizard de notas */
.progreso { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.alumno-actual { font-weight: 700; font-size: 18px; color: var(--text-strong); margin-bottom: 10px; }
.area-actual { font-size: 14px; color: var(--text-muted); margin-bottom: 14px; font-weight: 600; }

.competencia { padding: 14px 0; border-bottom: 1px solid var(--border); }
.competencia:last-child { border-bottom: none; }
.competencia .id { color: var(--text-muted); font-size: 12px; font-weight: 700; }
.competencia .nombre { font-size: 14px; color: var(--text); margin: 4px 0 10px; line-height: 1.4; }
.competencia .capacidades {
  display: none; font-size: 12px; color: var(--text-muted); margin-bottom: 8px;
  padding-left: 14px; line-height: 1.5;
}
.competencia .capacidades li { margin-bottom: 3px; }
.ver-capacidades {
  background: none; border: none; color: var(--primary); font-size: 12px;
  padding: 2px 0; cursor: pointer; margin-bottom: 8px;
}
.ver-capacidades:hover { text-decoration: underline; }

.notas-row { display: flex; gap: 6px; margin-bottom: 8px; }
.nota-btn {
  flex: 1; padding: 12px 4px; border: 2px solid var(--border-strong); border-radius: 8px;
  background: var(--card-bg); font-weight: 700; font-size: 15px; color: var(--text-muted); cursor: pointer;
}
.nota-btn:hover { border-color: var(--text-muted); }
.nota-btn.active[data-n="AD"] { background: #7c3aed; border-color: #7c3aed; color: white; }
.nota-btn.active[data-n="A"]  { background: #16a34a; border-color: #16a34a; color: white; }
.nota-btn.active[data-n="B"]  { background: #ca8a04; border-color: #ca8a04; color: white; }
.nota-btn.active[data-n="C"]  { background: #dc2626; border-color: #dc2626; color: white; }
.nota-btn[data-n="—"] { font-size: 18px; }
.nota-btn.active[data-n="—"] { background: #475569; border-color: #475569; color: white; }

textarea.conclusion {
  width: 100%; min-height: 60px; border: 2px solid var(--border-strong); border-radius: 8px;
  padding: 8px; font-family: inherit; font-size: 13px; resize: vertical; margin-top: 4px;
  background: var(--input-bg); color: var(--text);
}
textarea.conclusion:focus { outline: none; border-color: var(--primary); }

/* Instrumentos de evaluación */
.instrumentos-box {
  background: var(--soft-bg); border-radius: 8px; padding: 10px 12px;
  margin: 8px 0 10px; border: 1px dashed var(--border-strong);
}
.instrumentos-toggle {
  background: none; border: none; color: var(--primary); font-size: 12px;
  padding: 0; cursor: pointer; font-weight: 600;
}
.instrumentos-toggle:hover { text-decoration: underline; }
.instrumentos-list { margin-top: 8px; display: none; }
.instrumentos-list.open { display: block; }

.instr-row {
  display: grid; grid-template-columns: 90px 1fr 1fr 70px 32px;
  gap: 6px; align-items: center; margin-bottom: 6px; font-size: 12px;
}
.instr-row input[type="date"], .instr-row input[type="text"], .instr-row select {
  padding: 6px 8px; font-size: 12px; font-family: inherit;
  border: 1px solid var(--border-strong); border-radius: 6px;
  background: var(--input-bg); color: var(--text);
  width: 100%;
}
.instr-row select.calif { font-weight: 700; }
.instr-row select.calif[data-val="AD"] { color: #7c3aed; }
.instr-row select.calif[data-val="A"]  { color: #16a34a; }
.instr-row select.calif[data-val="B"]  { color: #ca8a04; }
.instr-row select.calif[data-val="C"]  { color: #dc2626; }
.btn-del-instr {
  background: #fee2e2; color: #991b1b; border: none; border-radius: 6px;
  width: 28px; height: 28px; cursor: pointer; font-size: 14px; padding: 0;
}
.btn-del-instr:hover { background: #fecaca; }
.btn-add-instr {
  background: var(--card-bg); color: var(--primary); border: 1px dashed var(--primary);
  border-radius: 6px; padding: 6px 10px; font-size: 12px; cursor: pointer; margin-top: 4px;
}
.btn-add-instr:hover { background: var(--hover-bg); }
.sugerido {
  font-size: 14px; color: var(--text-strong); margin-top: 10px; padding: 10px 14px;
  background: var(--hover-bg); border-radius: 8px; display: flex;
  align-items: center; gap: 10px; flex-wrap: wrap;
  border: 1px solid var(--border-strong);
}
.sugerido strong { color: var(--primary); font-size: 18px; }
.btn-aceptar-sugerido {
  background: #1e3a8a; color: white; border: none; border-radius: 6px;
  padding: 8px 14px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-aceptar-sugerido:hover { background: #1e40af; }
.ya-aplicado { color: #16a34a; font-size: 13px; font-weight: 600; }

.tip-instr {
  font-size: 13px; color: var(--text-muted); margin-bottom: 8px; line-height: 1.4;
}
.tip-instr strong { color: var(--text-strong); }

.flecha-abajo {
  text-align: center; font-size: 24px; color: #0ea5e9; margin-top: 4px;
  animation: bounce 1.2s ease-in-out infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* Resaltar el botón AD/A/B/C que coincide con la sugerencia */
.nota-btn.suggested:not(.active) {
  border-color: var(--primary); border-style: dashed; background: var(--hover-bg);
}

.notas-row.flash { animation: flashOk 0.6s ease-out; }
@keyframes flashOk {
  0%   { box-shadow: 0 0 0 0 rgba(14,165,233,0); }
  30%  { box-shadow: 0 0 0 4px rgba(14,165,233,0.4); }
  100% { box-shadow: 0 0 0 0 rgba(14,165,233,0); }
}

/* Aviso cuando la nota oficial difiere de la sugerencia */
.aviso-discrepancia {
  font-size: 13px; color: #92400e; margin-top: 10px; line-height: 1.5;
  padding: 10px 12px; background: #fef3c7; border-radius: 8px;
  border: 1px solid #fcd34d;
}
.aviso-discrepancia strong { color: #78350f; }

/* ============================================================
   Responsive: celular (<= 600px)
   ============================================================ */
@media (max-width: 600px) {
  body { padding: 10px; }
  .header { padding: 14px 16px; }
  .header h1 { font-size: 19px; }
  .header h2 { font-size: 16px; }
  .header p { font-size: 13px; }

  .card { padding: 12px; border-radius: 10px; }

  /* Instrumentos: pasan de 5 columnas a 3 filas (fecha+calif+×, tipo, nombre) */
  .instr-row {
    grid-template-columns: 1fr auto 32px;
    grid-template-rows: auto auto auto;
    gap: 6px 6px;
  }
  .instr-row > input[type="date"] { grid-column: 1; grid-row: 1; }
  .instr-row > select.calif       { grid-column: 2; grid-row: 1; min-width: 64px; }
  .instr-row > .btn-del-instr     { grid-column: 3; grid-row: 1; }
  .instr-row > select.tipo        { grid-column: 1 / -1; grid-row: 2; }
  .instr-row > input[type="text"] { grid-column: 1 / -1; grid-row: 3; }

  /* Más aire entre filas en mobile */
  .instr-row {
    padding-bottom: 10px; margin-bottom: 10px;
    border-bottom: 1px solid var(--border);
  }
  .instr-row:last-of-type { border-bottom: none; margin-bottom: 4px; }

  /* Inputs/selects más cómodos al tap */
  .instr-row input, .instr-row select { padding: 10px; font-size: 14px; }

  /* Botones AD/A/B/C un poco más altos en mobile */
  .nota-btn { padding: 14px 4px; font-size: 16px; }

  /* Sticky bottom bar más compacta */
  .actions { padding: 10px 0; gap: 6px; }
  .actions .btn-secondary { padding: 12px 10px; font-size: 14px; }
  .actions .btn-primary { padding: 14px 12px; font-size: 15px; }

  /* Pills de áreas: scroll horizontal si son muchas */
  #areasPills { display: flex; flex-wrap: wrap; gap: 4px; }
  .area-pill { padding: 8px 12px; font-size: 13px; margin: 0; }

  /* Sugerido más legible */
  .sugerido { font-size: 14px; }
  .sugerido strong { font-size: 20px; }
}

/* Bottom action bar sticky */
.actions {
  position: sticky; bottom: 0; background: var(--bg);
  padding: 12px 0; border-top: 1px solid var(--border); margin-top: 16px;
  display: flex; gap: 8px; align-items: center; z-index: 10;
}
