/* ============================================================
   CONVIVENCIA SOCARRAS — Hoja de estilos principal
   IED José Francisco Socarras · Jornada Tarde · 2026
   ============================================================ */

:root {
  --primary:        #1a56a0;
  --primary-dark:   #123e7a;
  --primary-light:  #3b7dd8;
  --primary-bg:     #eff6ff;
  --accent:         #0d9488;
  --accent-bg:      #f0fdfa;
  --bg:             #f0f4f8;
  --surface:        #ffffff;
  --text:           #1e293b;
  --text-muted:     #64748b;
  --border:         #e2e8f0;
  --success:        #16a34a;
  --success-bg:     #dcfce7;
  --warning:        #d97706;
  --warning-bg:     #fef9c3;
  --danger:         #dc2626;
  --danger-bg:      #fee2e2;
  --radius:         12px;
  --radius-sm:      8px;
  --radius-xs:      6px;
  --shadow:         0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.08);
  --header-h:       58px;
  --nav-h:          62px;
  --max-w:          600px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + 8px);
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
select, input, textarea { font-family: inherit; font-size: 15px; }

/* ── Header ─────────────────────────────────────────────────── */
.app-header {
  background: var(--primary);
  color: white;
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-md);
}

.header-brand { flex: 1; }
.header-brand h1 { font-size: 15px; font-weight: 700; line-height: 1.2; }
.header-brand p  { font-size: 11px; opacity: 0.75; margin-top: 1px; }

.header-action {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ── Bottom Nav ─────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 200;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  gap: 3px;
  cursor: pointer;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active { color: var(--primary); }
.nav-item .nav-icon { font-size: 22px; line-height: 1; }

/* ── Main container ─────────────────────────────────────────── */
.main {
  padding: 14px 14px 0;
  max-width: var(--max-w);
  margin: 0 auto;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 14px;
}

/* ── Stats grid ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 12px;
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-number {
  font-size: 34px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 500;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  touch-action: manipulation; /* Elimina el retraso de 300ms en móvil */
  -webkit-tap-highlight-color: transparent;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover, .btn-primary:active { background: var(--primary-dark); }

.btn-accent  { background: var(--accent); color: white; }
.btn-accent:hover { background: #0b7c77; }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: #e5edf5; }

.btn-ghost { background: transparent; color: var(--primary); padding: 8px 12px; }

.btn-full   { width: 100%; }
.btn-lg     { padding: 15px 24px; font-size: 16px; border-radius: var(--radius); }
.btn-sm     { padding: 7px 13px; font-size: 13px; }

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

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

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

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

.form-control {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px; /* Mínimo 16px en iOS para evitar zoom automático al enfocar */
  color: var(--text);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 160, 0.12);
}

.form-control::placeholder { color: #b0bec5; }

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

/* Checkboxes */
.check-group { display: flex; flex-direction: column; gap: 8px; }

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-xs);
  cursor: pointer;
}

.check-item input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.check-item label { font-size: 14px; cursor: pointer; flex: 1; }

/* Autocomplete tag input */
.tag-input-wrap {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  background: white;
  min-height: 46px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  cursor: text;
}

.tag-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 160, 0.12);
}

.tag {
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: 20px;
  padding: 3px 10px 3px 10px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tag-remove {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.tag-input-field {
  border: none;
  outline: none;
  font-size: 16px; /* Evitar zoom iOS */
  flex: 1;
  min-width: 120px;
  background: transparent;
}

.autocomplete-list {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  box-shadow: var(--shadow-md);
  max-height: 180px;
  overflow-y: auto;
  margin-top: -6px;
}

.autocomplete-item {
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.selected { background: var(--primary-bg); color: var(--primary); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-activo      { background: var(--success-bg); color: var(--success); }
.badge-seguimiento { background: var(--warning-bg); color: var(--warning); }
.badge-cerrado     { background: #f1f5f9; color: #64748b; }
.badge-tipo1       { background: #dbeafe; color: #1d4ed8; }
.badge-tipo2       { background: #fce7f3; color: #be185d; }
.badge-tipo3       { background: #fef3c7; color: #92400e; }
.badge-falta-leve  { background: #f0fdf4; color: #15803d; }
.badge-falta-grave { background: #fff7ed; color: #c2410c; }
.badge-falta-gravisima { background: var(--danger-bg); color: var(--danger); }

/* ── Case list items ─────────────────────────────────────────── */
.case-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.case-item:last-child { border-bottom: none; }
.case-item:hover { background: var(--bg); margin: 0 -16px; padding: 13px 16px; border-radius: var(--radius-sm); }

.case-code {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-bg);
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 1px;
}

.case-body { flex: 1; min-width: 0; }
.case-student { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case-meta    { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Timeline ───────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 22px; }

.timeline::before {
  content: '';
  position: absolute;
  left: 7px; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--border);
}

.tl-item { position: relative; margin-bottom: 18px; }

.tl-item::before {
  content: '';
  position: absolute;
  left: -18px; top: 5px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid white;
  box-shadow: 0 0 0 2px var(--primary);
}

.tl-date    { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; font-weight: 500; }
.tl-title   { font-size: 14px; font-weight: 600; }
.tl-body    { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Section header ─────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title { font-size: 16px; font-weight: 700; }
.section-link  { font-size: 13px; color: var(--primary); font-weight: 600; }

/* ── Search bar ─────────────────────────────────────────────── */
.search-wrap { position: relative; margin-bottom: 12px; }
.search-wrap .form-control { padding-left: 40px; }
.search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

/* ── Filter chips ───────────────────────────────────────────── */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  white-space: nowrap;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.chip.active { background: var(--primary); border-color: var(--primary); color: white; }
.chip:hover  { border-color: var(--primary); color: var(--primary); }

/* ── FAB ────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 14px);
  right: 16px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 28px;
  border: none;
  box-shadow: 0 4px 16px rgba(26, 86, 160, 0.4);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
  z-index: 100;
}
.fab:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(26, 86, 160, 0.5); }

/* ── Chart placeholder ──────────────────────────────────────── */
.chart-ph {
  background: var(--bg);
  border-radius: var(--radius-sm);
  height: 150px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  border: 2px dashed var(--border);
}

/* ── Bar chart (CSS only) ───────────────────────────────────── */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }

.bar-row { display: flex; align-items: center; gap: 10px; }

.bar-label { font-size: 12px; color: var(--text-muted); width: 140px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.bar-track {
  flex: 1;
  height: 18px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.6s ease;
}

.bar-value { font-size: 12px; font-weight: 700; color: var(--text); width: 24px; text-align: right; }

/* ── Admin list ─────────────────────────────────────────────── */
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.admin-row:last-child { border-bottom: none; }
.admin-row-label { font-weight: 500; }
.admin-row-sub   { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* ── Pill tabs (Casos page) ─────────────────────────────────── */
.pill-tabs {
  display: flex;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  overflow-x: auto;          /* Desplazamiento si hay muchas pestañas */
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.pill-tabs::-webkit-scrollbar { display: none; }

.pill-tab {
  flex: 1;
  text-align: center;
  padding: 9px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: transparent;
}

.pill-tab.active { background: var(--primary); color: white; box-shadow: var(--shadow); }

/* ── Student profile ────────────────────────────────────────── */
.student-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 22px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.student-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.student-name { font-size: 17px; font-weight: 700; }
.student-curso { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 42px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }

/* ── Divider ────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 8px 0; }

/* ── Info row (detail view) ─────────────────────────────────── */
.info-row {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.info-row:last-child { border-bottom: none; }
.info-key   { color: var(--text-muted); font-size: 13px; width: 130px; flex-shrink: 0; }
.info-value { font-weight: 500; }

/* ── LOGIN PAGE ─────────────────────────────────────────────── */
.login-bg {
  min-height: 100vh;
  background: linear-gradient(150deg, #1a56a0 0%, #0d9488 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 32px 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-escudo {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px;
  margin: 0 auto 12px;
  box-shadow: 0 4px 14px rgba(26,86,160,0.3);
}

.login-logo h2 { font-size: 16px; font-weight: 800; color: var(--text); line-height: 1.3; }
.login-logo p  { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.demo-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 14px;
}

/* ── Responsive ─────────────────────────────────────────────── */

/* Pantallas angostas (< 380px — teléfonos pequeños) */
@media (max-width: 380px) {
  .main { padding: 10px 10px 0; }
  .card { padding: 14px 12px; }
  .stat-number { font-size: 28px; }
  .pill-tab { font-size: 12px; padding: 7px 8px; }
  .btn-lg { padding: 13px 18px; font-size: 15px; }
  /* Grids de 2 columnas en formularios → una columna */
  .form-2col { grid-template-columns: 1fr !important; }
  .bar-label { width: 100px; }
}

/* Pantallas medianas hacia arriba (≥ 600px — tablet y escritorio) */
@media (min-width: 600px) {
  .main { padding: 20px 20px 0; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  /* En escritorio la nav inferior puede ir al costado o quedarse abajo */
  body { padding-bottom: calc(var(--nav-h) + 8px); }
}

/* Pantallas grandes (≥ 900px — escritorio) */
@media (min-width: 900px) {
  .main { max-width: 720px; }
  .login-card { padding: 40px 36px; }
}

/* ── Impresión / PDF ────────────────────────────────────────── */
@media print {
  /* Ocultar elementos de navegación e interfaz */
  .bottom-nav,
  .fab,
  .app-header,
  .chips,
  .btn-print-hide,
  .search-wrap,
  input[type="text"],
  input[type="search"] { display: none !important; }

  /* Eliminar márgenes de pantalla */
  body {
    background: white !important;
    padding-bottom: 0 !important;
    font-size: 13px;
    color: #000;
  }

  .main {
    padding: 0 !important;
    max-width: 100% !important;
  }

  /* Cards sin sombra en papel */
  .card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    break-inside: avoid;
    margin-bottom: 10px !important;
    padding: 12px !important;
  }

  /* Encabezado de impresión */
  .print-header {
    display: block !important;
    text-align: center;
    border-bottom: 2px solid #1a56a0;
    padding-bottom: 10px;
    margin-bottom: 14px;
  }

  /* Stats más compactas */
  .stats-grid { gap: 6px !important; }
  .stat-card  { padding: 8px !important; }
  .stat-number { font-size: 24px !important; }

  /* Barras visibles en impresión */
  .bar-fill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge    { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge-activo, .badge-seguimiento, .badge-cerrado { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  /* Forzar nueva página si es necesario */
  .print-page-break { page-break-before: always; }
}

/* Encabezado de impresión (oculto en pantalla) */
.print-header { display: none; }

/* Soporte para muesca/notch en iPhone X en adelante */
@supports (padding: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  }
  body {
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
  }
}
