/* ============================================================
   ESAC · Sistema de TPs · Estilos globales
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;1,9..144,400&family=Inter:wght@400;500;600;700&display=swap');

/* Variables */
:root {
  --azul:        #0D47A1;
  --azul-light:  #1565C0;
  --naranja:     #FF6F00;
  --bg:          #F4F0EB;
  --bg-card:     #FFFFFF;
  --text:        #1A1A1A;
  --text-muted:  #6B6B6B;
  --border:      #E0DAD3;
  --success:     #2E7D32;
  --danger:      #C62828;
  --warning:     #E65100;
  --sidebar-w:   240px;
  --radius:      12px;
  --shadow:      0 1px 4px rgba(0,0,0,.08);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── LOGIN ─────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,0,0,.10);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo img { max-width: 280px; width: 100%; height: auto; }
.login-logo h2 {
  font-family: 'Fraunces', serif;
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: .4rem;
}

/* ── LAYOUT CON SIDEBAR ────────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .logo { height: 36px; }
.sidebar-brand .rol {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: .25rem;
}
.sidebar-nav {
  padding: 1rem .75rem;
  flex: 1;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .75rem;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: var(--bg); color: var(--text); }
.sidebar-nav a.active { background: var(--azul); color: #fff; }
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav .nav-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: .75rem .75rem .25rem;
}
.sidebar-user {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-user .avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--azul);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
  font-weight: 700;
  flex-shrink: 0;
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name {
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user .user-email {
  font-size: .72rem;
  color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user .btn-logout {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: .25rem;
  border-radius: 6px;
  transition: color .15s;
}
.sidebar-user .btn-logout:hover { color: var(--danger); }

/* Main content */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1100px;
}
.page-header {
  margin-bottom: 1.75rem;
}
.page-header .eyebrow {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--naranja);
  margin-bottom: .25rem;
}
.page-header h1 {
  font-family: 'Fraunces', serif;
  font-size: 2rem;
  font-weight: 500;
  line-height: 1.2;
}
.page-header h1 span { color: var(--naranja); font-style: italic; }

/* ── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.card-body { padding: 1.25rem 1.5rem; }
.card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.card-header h2 {
  font-family: 'Fraunces', serif;
  font-size: 1.2rem;
  font-weight: 500;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}
.stat-card .label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .4rem;
}
.stat-card .value {
  font-family: 'Fraunces', serif;
  font-size: 2.5rem;
  font-weight: 500;
  color: var(--azul);
  line-height: 1;
}
.stat-card .sublabel {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .3rem;
}
.stat-card.highlight { border-color: var(--azul); }

/* ── TABLA ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: .6rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
td {
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ── BADGES ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .65rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-green  { background: #E8F5E9; color: var(--success); }
.badge-red    { background: #FFEBEE; color: var(--danger); }
.badge-orange { background: #FFF3E0; color: var(--warning); }
.badge-blue   { background: #E3F2FD; color: var(--azul); }
.badge-gray   { background: #F0F0F0; color: var(--text-muted); }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── BOTONES ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .55rem 1.1rem;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary   { background: var(--azul); color: #fff; }
.btn-primary:hover { background: var(--azul-light); }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger    { background: #FFEBEE; color: var(--danger); }
.btn-danger:hover { background: #FFCDD2; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── FORMULARIOS ───────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .4rem;
}
input[type=text], input[type=email], input[type=password],
input[type=date], input[type=number], select, textarea {
  width: 100%;
  padding: .65rem .9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .92rem;
  font-family: 'Inter', sans-serif;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(13,71,161,.12);
}
textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .3rem;
}
.form-error {
  font-size: .82rem;
  color: var(--danger);
  margin-top: .4rem;
}

/* ── ALERT ─────────────────────────────────────────────────── */
.alert {
  padding: .85rem 1.1rem;
  border-radius: 8px;
  font-size: .9rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alert-danger  { background: #FFEBEE; color: var(--danger); border-color: #FFCDD2; }
.alert-success { background: #E8F5E9; color: var(--success); border-color: #C8E6C9; }
.alert-warning { background: #FFF3E0; color: var(--warning); border-color: #FFE0B2; }

/* ── MODAL ─────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-family: 'Fraunces', serif;
  font-size: 1.25rem;
  font-weight: 500;
}
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.3rem; line-height: 1;
  padding: .25rem;
}
.modal-body { padding: 1.25rem 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
}

/* ── PROGRESO ──────────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-top: .3rem;
}
.progress-bar .fill {
  height: 100%;
  background: var(--azul);
  border-radius: 99px;
  transition: width .4s;
}
.progress-bar .fill.warn { background: var(--warning); }
.progress-bar .fill.bad  { background: var(--danger); }

/* ── FOTOS GRID (alumno) ───────────────────────────────────── */
.fotos-grid {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-top: 1rem;
}
.foto-slot {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: row;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s;
  background: var(--bg);
  min-height: 130px;
  position: relative;
}
.foto-slot:hover { border-color: var(--azul); }
.foto-slot.filled { border-style: solid; border-color: var(--success); }

/* Área de imagen — izquierda */
.foto-slot-img {
  width: 170px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  background: #ddd9d3;
  display: flex;
  align-items: center;
  justify-content: center;
}
.foto-slot-img img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}

/* Área de contenido — derecha */
.foto-slot-body {
  flex: 1;
  padding: .85rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: .35rem;
}
.foto-slot .foto-label {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  padding: 0;
  z-index: 1;
  line-height: 1.4;
}
.foto-slot .foto-hint {
  font-size: .78rem;
  color: var(--text-muted);
}
.foto-slot .foto-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--azul);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
  flex-shrink: 0;
}
.foto-slot.filled .foto-num { background: var(--success); }
.foto-slot .btn-remove-foto {
  position: absolute; top: .4rem; right: .4rem;
  background: rgba(0,0,0,.55); border: none;
  color: #fff; border-radius: 50%;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: .9rem; z-index: 2;
}

/* ── NOTA BADGE ────────────────────────────────────────────── */
.nota-badge {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem;
  flex-shrink: 0;
}
.nota-badge.alta   { background: #1B5E20; color: #fff; }
.nota-badge.media  { background: #2E7D32; color: #fff; }
.nota-badge.baja   { background: #F57F17; color: #fff; }
.nota-badge.repro  { background: var(--danger); color: #fff; }

/* ── COMISIÓN CHIP ─────────────────────────────────────────── */
.comision-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--azul);
  color: #fff;
  border-radius: 8px;
  padding: .3rem .6rem;
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  min-width: 70px;
}
.comision-chip .turno {
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: .8;
  margin-top: .1rem;
}

/* ── LISTA ITEMS ───────────────────────────────────────────── */
.item-list { display: flex; flex-direction: column; gap: .5rem; }
.item-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow .15s;
}
.item-row:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.item-row .item-body { flex: 1; min-width: 0; }
.item-row .item-title {
  font-weight: 600;
  font-size: .95rem;
}
.item-row .item-meta {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .1rem;
}
.item-actions { display: flex; gap: .4rem; flex-shrink: 0; }

/* ── TABS ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}
.tab-btn {
  padding: .6rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.tab-btn.active { color: var(--azul); border-bottom-color: var(--azul); }
.tab-content.hidden { display: none; }
.badge-count { display:inline-flex; align-items:center; justify-content:center; background:var(--border); color:var(--text-muted); font-size:.72rem; font-weight:700; border-radius:10px; padding:1px 7px; margin-left:.3rem; }

/* ── SELECTOR DE DÍAS ──────────────────────────────────────── */
.dias-grid { display:flex; gap:.35rem; flex-wrap:wrap; }
.dia-btn {
  padding:.28rem .55rem;
  border:1.5px solid var(--azul);
  border-radius:8px;
  background:#fff;
  cursor:pointer;
  font-size:.78rem;
  font-weight:600;
  color:var(--azul);
  transition:background .12s, color .12s;
  user-select:none;
}
.dia-btn:hover { background:var(--azul-light); color:#fff; }
.dia-btn.on { background:var(--azul); color:#fff; }

/* ── CAMBIO DE CONTRASEÑA (primer ingreso) ─────────────────── */
.cambio-pass-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.cambio-pass-overlay.hidden { display: none; }

/* ── UTILIDADES ────────────────────────────────────────────── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .85rem; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.fw-600 { font-weight: 600; }
.ml-auto { margin-left: auto; }
.hidden { display: none !important; }
.w-100 { width: 100%; }

/* ── MENSAJERÍA ────────────────────────────────────────────── */
.msg-list { display:flex; flex-direction:column; }
.msg-row {
  display:flex;
  align-items:stretch;
  border-bottom:1px solid var(--border);
  transition:background .12s;
}
.msg-row:last-child { border-bottom:none; }
.msg-row.unread { background:#f0f5ff; }
.msg-row-link {
  display:flex;
  align-items:center;
  gap:.9rem;
  flex:1;
  padding:.9rem 1.25rem;
  text-decoration:none;
  color:var(--text);
  min-width:0;
}
.msg-row:hover .msg-row-link { background: var(--bg); }
.msg-avatar {
  width:40px; height:40px; border-radius:50%;
  background:var(--azul); color:#fff;
  display:flex; align-items:center; justify-content:center;
  font-size:.9rem; font-weight:700; flex-shrink:0;
}
.msg-body { flex:1; min-width:0; }
.msg-top { display:flex; align-items:baseline; justify-content:space-between; gap:.5rem; margin-bottom:.15rem; }
.msg-from { font-size:.88rem; font-weight:600; white-space:nowrap; }
.msg-date { font-size:.75rem; color:var(--text-muted); white-space:nowrap; flex-shrink:0; }
.msg-asunto { font-size:.9rem; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.msg-row.unread .msg-asunto { color:var(--azul); }
.msg-preview { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; font-size:.82rem; }
.msg-badge { margin-left:.5rem; flex-shrink:0; }
.msg-delete {
  align-self:center;
  margin-right:.75rem;
  opacity:0;
  transition:opacity .15s;
}
.msg-row:hover .msg-delete { opacity:1; }

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); transition: transform .25s; width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 1.25rem 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header h1 { font-size: 1.5rem; }
}
