/*
  Sistema de Reportes - Secundaria Ipanti
  Paleta placeholder (sol naranja + verde + blanco, tomada de la impresion general
  de ipanti.edu.mx). SUSTITUIR --color-primary/--color-secondary por los hex exactos
  de marca y --font-base por la tipografia oficial en cuanto el usuario los provea.
*/

:root {
  --color-primary: #E8792A;
  --color-primary-dark: #C7601A;
  --color-primary-light: #FBEAD9;
  --color-secondary: #4C8C4A;
  --color-secondary-light: #E5F1E4;
  --color-bg: #FAFAF8;
  --color-surface: #FFFFFF;
  --color-text: #2A2622;
  --color-text-muted: #6B6459;
  --color-border: #E4E0D8;
  --color-danger: #C43D3D;
  --color-danger-light: #FBEAEA;
  --color-warning: #B8860B;
  --color-warning-light: #FBF3DD;
  --color-success: #2E7D32;
  --color-success-light: #E8F5E9;

  --sol-icon: url("../assets/sol-ipanti.png");

  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --max-width: 1180px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-base);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0 0 0.5em 0;
  font-weight: 700;
  line-height: 1.25;
}

p { margin: 0 0 1em 0; }

a { color: var(--color-primary-dark); }

button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
}

/* ---------- Layout ---------- */

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 16px;
}

.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  max-width: var(--max-width);
  margin: 0 auto;
  gap: 12px;
}

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

.brand .sol {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-image: var(--sol-icon);
  background-size: contain;
  flex-shrink: 0;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.campana-btn {
  position: relative;
  font-size: 1.05rem;
  line-height: 1;
}

.badge-campana {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--color-danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.toast-contenedor {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}

.toast {
  background: var(--color-danger-light);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.88rem;
  box-shadow: var(--shadow-md);
  opacity: 1;
  transition: opacity 0.4s ease;
}

.toast-salir {
  opacity: 0;
}

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.tab-btn {
  padding: 12px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.tab-btn.activo {
  color: var(--color-primary-dark);
  border-bottom-color: var(--color-primary);
}

.page {
  padding: 20px 0 60px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

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

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 720px) {
  .grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Formularios ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.field input,
.field select,
.field textarea {
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

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

.password-wrap {
  position: relative;
  display: flex;
}
.password-wrap input {
  padding-right: 42px;
}
.btn-ojito {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
}
.btn-ojito svg { width: 19px; height: 19px; }
.btn-ojito:hover { background: var(--color-primary-light); color: var(--color-primary-dark); }

.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.form-row .field { flex: 1 1 160px; }

/* ---------- Botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.btn:hover { filter: brightness(0.95); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-secondary { background: var(--color-secondary); color: #fff; }
.btn-outline { background: transparent; border-color: var(--color-border); color: var(--color-text); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--color-primary-dark); border: none; padding: 6px 10px; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* ---------- Tablas ---------- */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

th {
  color: var(--color-text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody tr:hover { background: var(--color-primary-light); }

/* Encabezados de tabla que a la vez son controles de filtro (ej. consolidados) */
.tabla-filtros th {
  padding: 6px 8px;
  vertical-align: middle;
}
.tabla-filtros th select,
.tabla-filtros th input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.8rem;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}
.tabla-filtros th input[type="date"] { min-width: 128px; }

/* ---------- Estados / badges ---------- */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-borrador { background: #EEE; color: #555; }
.badge-enviado_coordinacion { background: var(--color-primary-light); color: var(--color-primary-dark); }
.badge-pendiente_direccion { background: var(--color-warning-light); color: var(--color-warning); }
.badge-autorizado { background: var(--color-success-light); color: var(--color-success); }
.badge-rechazado { background: var(--color-danger-light); color: var(--color-danger); }
.badge-enviado_padres { background: var(--color-secondary-light); color: var(--color-secondary); }
.badge-consolidado { background: var(--color-success-light); color: var(--color-success); }

/* ---------- Alertas ---------- */

.alert {
  position: relative;
  padding: 12px 34px 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.92rem;
}
.alert-error { background: var(--color-danger-light); color: var(--color-danger); }
.alert-success { background: var(--color-success-light); color: var(--color-success); }
.alert-info { background: var(--color-primary-light); color: var(--color-primary-dark); }
.alert-cerrar {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: inherit;
  font-size: 1.15rem;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
  opacity: 0.6;
}
.alert-cerrar:hover { opacity: 1; }

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, var(--color-primary-light) 0%, var(--color-bg) 55%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 32px 28px;
  text-align: center;
}

.login-card .sol {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background-image: var(--sol-icon);
  background-size: contain;
}

.login-card h1 {
  font-size: 1.2rem;
  margin-bottom: 4px;
}

.login-card .subt {
  color: var(--color-text-muted);
  font-size: 0.88rem;
  margin-bottom: 24px;
}

.login-card form { text-align: left; }

/* ---------- Pie de pagina ---------- */

.site-footer {
  text-align: center;
  padding: 18px 16px;
  font-size: 0.8rem;
  color: #000;
}
.site-footer a {
  color: #000;
  font-weight: 600;
  text-decoration: underline;
}

/* ---------- Utilidades ---------- */

.muted { color: var(--color-text-muted); }
.text-sm { font-size: 0.85rem; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}

.modal-box {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 20px;
  width: 100%;
  max-width: 720px;
}
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
}

/* Vista imprimible del consolidado (usada dentro del iframe/ventana de preview) */
@media print {
  .no-print { display: none !important; }
}

/* ---------- Horarios (subsistema 2) ---------- */

.horario-grid { min-width: 720px; }
.horario-grid th, .horario-grid td { text-align: center; }
.horario-grid .hora-celda {
  text-align: left;
  white-space: nowrap;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.horario-grid .fila-descanso td {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-weight: 600;
  font-size: 0.8rem;
  text-align: center;
  white-space: nowrap;
}
.horario-grid .celda-vacia { color: var(--color-border); }
.horario-grid .celda-vacia-explicada { cursor: help; }
.celda-hueco-icono { font-size: 11px; opacity: .55; }
.celda-vacia-explicada:hover .celda-hueco-icono { opacity: 1; }

.btn-disp {
  width: 100%;
  min-width: 84px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--color-bg);
  color: var(--color-text-muted);
}
.btn-disp-si {
  background: var(--color-success-light);
  color: var(--color-success);
  border-color: var(--color-success);
}
.btn-disp-reservado {
  background: var(--color-border);
  color: var(--color-text-muted);
  border-color: var(--color-border);
}
.btn-disp-reservado:disabled { cursor: not-allowed; }
.celda-aviso-parcial { font-size: 0.68rem; color: var(--color-text-muted); margin-top: 3px; line-height: 1.2; }

.celda-materia {
  position: relative;
  border-left: 4px solid var(--color-primary);
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  text-align: left;
  min-width: 110px;
}
.celda-materia-nombre { font-weight: 700; font-size: 0.85rem; padding-right: 18px; }
.celda-profesor { font-size: 0.75rem; color: var(--color-text-muted); }
.celda-profesor-fila { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-top: 2px; }

.celda-btn-reloj, .celda-btn-choque {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 2px;
  border-radius: 3px;
  flex-shrink: 0;
}
/* El reloj va inline, al margen derecho del mismo renglon del profesor. */
.celda-btn-reloj { opacity: 0.6; }
.celda-btn-reloj:hover { opacity: 1; background: var(--color-bg-muted, rgba(0,0,0,0.06)); }
/* El choque va en la esquina superior DERECHA de toda la celda. */
.celda-btn-choque { position: absolute; top: 2px; right: 2px; color: #c43d3d; }
.celda-btn-choque:hover { background: rgba(196,61,61,0.12); }

.celda-permutado {
  font-size: 0.72rem;
  color: var(--color-primary-dark, #8a5a00);
  font-style: italic;
  margin-top: 2px;
  cursor: pointer;
  text-decoration: underline dotted;
}

.celda-permutable { cursor: grab; }
.celda-permutable:active { cursor: grabbing; }
.celda-seleccionada { outline: 2px dashed var(--color-primary); outline-offset: -2px; }

.horario-grid-mini { min-width: 480px; }
.horario-grid-mini th, .horario-grid-mini td { padding: 4px 6px; font-size: 0.75rem; }

.badge-version-optima { background: var(--color-success-light); color: var(--color-success); }
.badge-version-alternativa_1 { background: var(--color-primary-light); color: var(--color-primary-dark); }
.badge-version-alternativa_2 { background: var(--color-secondary-light); color: var(--color-secondary); }
