/* Bitácora Cernícalo y Halcón */

:root {
  --teal:    #11743a;
  --navy:    #1e3a5f;
  --pink:    #ec4899;
  --bg:      #f0fdf9;
  --surface: #ffffff;
  --border:  #d1ede8;
  --text:    #1a2e3b;
  --muted:   #6b7280;

  /* Territorios */
  --corp-color: #22863a;
  --crea-color: #7c3aed;
  --cara-color: #11743a;
  --afec-color: #db2777;
  --soci-color: #d97706;
  --espi-color: #1e3a5f;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
  margin: 0;
}

/* ─── Layout ──────────────────────────────────────────────────────────────── */
#app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  background: var(--teal);
  padding: 10px 16px 8px;
  padding-top: calc(10px + env(safe-area-inset-top));
  box-shadow: 0 2px 12px rgba(14,159,159,.35);
  display: flex; align-items: center; gap: 10px;
}
#app-header h1 {
  font-size: 15px; font-weight: 700; color: #fff;
  margin: 0; flex: 1; letter-spacing: .02em;
}
#header-user-name {
  font-size: 13px; color: rgba(255,255,255,.85); font-weight: 600;
}
#header-etapa {
  display: none;
  font-size: 11px; font-weight: 700;
  background: rgba(255,255,255,.2);
  color: #fff;
  border-radius: 20px; padding: 2px 10px;
}
#guiadora-bar {
  display: none;
  background: var(--navy);
  color: rgba(255,255,255,.8);
  font-size: 11px; text-align: center;
  padding: 4px;
  letter-spacing: .05em;
}

#app-main {
  padding-top: 64px;
  padding-bottom: 72px;
  min-height: 100vh;
}
#app-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: var(--navy);
  border-top: 2px solid rgba(255,255,255,.08);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ─── Navegación ──────────────────────────────────────────────────────────── */
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 8px 4px 6px; cursor: pointer;
  border: none; background: none;
  color: rgba(255,255,255,.45);
  font-size: 10px; gap: 3px;
  transition: color .15s;
  min-height: 56px;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: #7ee8e8; }

/* ─── Vistas ──────────────────────────────────────────────────────────────── */
.view { display: none; padding: 14px 14px 10px; }

/* ─── Login ───────────────────────────────────────────────────────────────── */
#view-login {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 100vh;
  padding: 24px 20px; background: linear-gradient(160deg, #11743a 0%, #1e3a5f 100%);
}
.login-logo { width: 72px; height: 72px; object-fit: contain; margin-bottom: 8px; display: block; margin-left: auto; margin-right: auto; }
.login-title {
  font-size: 22px; font-weight: 800; color: #fff;
  text-align: center; margin: 0 0 4px;
  letter-spacing: -.01em;
}
.login-subtitle { font-size: 13px; color: rgba(255,255,255,.7); text-align: center; margin: 0 0 28px; }
.login-card {
  background: #fff; border-radius: 20px;
  padding: 24px 20px; width: 100%; max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.login-card label { font-size: 13px; font-weight: 600; color: var(--navy); display: block; margin-bottom: 4px; }
.login-card .input-field { margin-bottom: 14px; }
.login-slogan {
  font-size: 12px; color: rgba(255,255,255,.6);
  text-align: center; margin-top: 20px; font-style: italic;
}

/* ─── Inputs / Buttons ────────────────────────────────────────────────────── */
.input-field {
  width: 100%; padding: 11px 14px; border-radius: 12px;
  border: 1.5px solid var(--border); background: #fff;
  font-size: 15px; color: var(--text);
  outline: none; transition: border-color .15s;
}
.input-field:focus { border-color: var(--teal); }
textarea.input-field { resize: vertical; min-height: 80px; }

.btn-primary {
  width: 100%; padding: 13px; border-radius: 12px;
  background: var(--teal); color: #fff;
  font-size: 15px; font-weight: 700;
  border: none; cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-primary:hover  { background: #0d5c2e; }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .6; cursor: default; }

.btn-secondary {
  padding: 10px 18px; border-radius: 12px;
  background: var(--bg); color: var(--navy);
  font-size: 14px; font-weight: 600;
  border: 1.5px solid var(--border); cursor: pointer;
  transition: background .15s;
}
.btn-secondary:hover { background: #ddf3ee; }

/* Criterios de la evaluación de una actividad (spec 004): botón que se prende. */
.chip-criterio {
  padding: 10px 14px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--border); background: #fff;
  color: var(--navy); font-size: 14px; font-weight: 600;
}
.chip-criterio[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: #fff; }
.chip-criterio[aria-pressed="true"]::before { content: '✓ '; }

.btn-ghost {
  background: none; border: none; cursor: pointer;
  color: var(--teal); font-size: 14px; font-weight: 600;
  padding: 6px 0;
}

.btn-icon {
  background: none; border: none; cursor: pointer;
  font-size: 18px; padding: 4px 8px; border-radius: 8px;
  color: var(--muted); transition: background .15s;
}
.btn-icon:hover { background: var(--border); }

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: 16px;
  padding: 16px; margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  border: 1px solid var(--border);
}
.card-clickable { cursor: pointer; transition: box-shadow .15s, transform .1s; }
.card-clickable:active { transform: scale(.98); box-shadow: none; }

/* ─── Alerts ──────────────────────────────────────────────────────────────── */
.alert-error {
  background: #fef2f2; color: #dc2626;
  border-radius: 10px; padding: 10px 14px;
  font-size: 13px; display: none; margin-top: 10px;
}

/* ─── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff;
  padding: 10px 20px; border-radius: 24px;
  font-size: 13px; font-weight: 600;
  z-index: 100; pointer-events: none;
  opacity: 0; transition: opacity .2s;
  white-space: nowrap; max-width: 90vw;
}
#toast.show { opacity: 1; }
#toast.error { background: #dc2626; }

/* ─── Dashboard — Inicio ──────────────────────────────────────────────────── */
.etapa-hero {
  text-align: center;
  padding: 8px 0 4px;
  margin-bottom: 16px;
}
.etapa-hero-img {
  width: 110px; height: 110px;
  object-fit: contain;
  margin-bottom: 10px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.15));
}
.etapa-hero-emoji { font-size: 72px; margin-bottom: 10px; line-height: 1; }
.etapa-hero-nombre {
  font-size: 20px; font-weight: 800; color: var(--navy);
  margin-bottom: 8px;
}

.etapa-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--teal); color: #fff;
  border-radius: 20px; padding: 5px 16px;
  font-size: 13px; font-weight: 700;
}

.etapa-meta {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  margin-top: 10px;
}
.meta-pill {
  display: inline-flex; align-items: center;
  border: 1.5px solid; border-radius: 20px;
  padding: 3px 12px; font-size: 12px; font-weight: 600;
}
.meta-pill--compania {
  background: rgba(30,58,95,.08); color: var(--navy);
  border-color: rgba(30,58,95,.2);
}

/* ─── Progreso global ─────────────────────────────────────────────────────── */
.progreso-global {
  background: var(--surface); border-radius: 16px;
  padding: 14px 16px; margin-bottom: 16px;
  border: 1.5px solid var(--teal);
  box-shadow: 0 2px 8px rgba(14,159,159,.1);
}
.progreso-global__header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px;
  font-size: 13px; font-weight: 700; color: var(--navy);
}
.progreso-global__pct {
  font-size: 24px; font-weight: 900; color: var(--teal); line-height: 1;
}
.progreso-global__bar-wrap {
  background: var(--border); border-radius: 6px;
  height: 10px; overflow: hidden; margin-bottom: 6px;
}
.progreso-global__bar {
  height: 100%; background: var(--teal); border-radius: 6px;
  transition: width .6s ease;
}
.progreso-global__sub {
  font-size: 11px; color: var(--muted); text-align: right;
}

.territorios-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin-bottom: 14px;
}
.territorio-card {
  border-radius: 16px; padding: 14px 12px;
  cursor: pointer; transition: transform .1s;
  color: #fff; position: relative; overflow: hidden;
  min-height: 100px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.territorio-card:active { transform: scale(.97); }
.territorio-card .t-img   { width: 52px; height: 52px; object-fit: contain; margin-bottom: 6px; filter: drop-shadow(0 2px 8px rgba(0,0,0,.25)); }
.territorio-card .t-label { font-size: 13px; font-weight: 700; line-height: 1.2; }
.territorio-card .t-sub   { font-size: 10px; opacity: .8; margin-top: 2px; }

.progress-bar-wrap {
  background: rgba(255,255,255,.25); border-radius: 4px;
  height: 5px; margin-top: 8px; overflow: hidden;
}
.progress-bar {
  height: 100%; background: #fff; border-radius: 4px;
  transition: width .4s ease;
}
.progress-pct {
  font-size: 10px; font-weight: 700;
  opacity: .9; margin-top: 2px;
}

/* ─── Territorio — Vista desafíos ─────────────────────────────────────────── */
.territorio-header {
  margin: -14px -14px 16px;
  padding: 18px 16px 14px;
  color: #fff;
}
.territorio-header .t-header-img { width: 80px; height: 80px; object-fit: contain; margin: 8px 0 4px; filter: drop-shadow(0 4px 12px rgba(0,0,0,.25)); display: block; }
.territorio-header .back-btn {
  background: rgba(255,255,255,.2); border: none; border-radius: 10px;
  color: #fff; font-size: 18px; padding: 4px 12px;
  cursor: pointer; margin-bottom: 8px; display: inline-block;
}
.territorio-header h2 { font-size: 22px; font-weight: 800; margin: 6px 0 2px; }
.territorio-header .t-animal { font-size: 13px; opacity: .8; margin: 0; }
.territorio-header .t-progress {
  margin-top: 10px;
  background: rgba(255,255,255,.25); border-radius: 6px; height: 8px; overflow: hidden;
}
.territorio-header .t-progress-fill { height: 100%; background: #fff; border-radius: 6px; transition: width .4s; }

.desafios-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 24px; }

.desafio-grupo-header {
  font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); padding: 10px 2px 4px; margin-top: 6px;
}

.desafio-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; transition: background .15s;
}
.desafio-item:hover { background: #f8fffe; }
.desafio-item.done { background: #f0fdf4; border-color: #bbf7d0; }
.desafio-item.done .desafio-texto { text-decoration: line-through; color: var(--muted); }

.desafio-item input[type="checkbox"] {
  width: 20px; height: 20px; flex-shrink: 0;
  border-radius: 6px; cursor: pointer; margin-top: 1px;
  accent-color: var(--teal);
}
.desafio-texto { font-size: 14px; line-height: 1.45; }

/* dirigente: no puede modificar */
.readonly .desafio-item { cursor: default; }
.readonly .desafio-item input { pointer-events: none; }

/* ─── Desafíos personales ─────────────────────────────────────────────────── */
.personales-section {
  border-top: 2px dashed var(--border); padding-top: 16px; margin-top: 4px;
}
.personales-section h3 {
  font-size: 14px; font-weight: 700; color: var(--navy);
  margin: 0 0 12px; text-transform: uppercase; letter-spacing: .04em;
}
.personal-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  background: var(--bg); border: 1px dashed var(--border);
  margin-bottom: 8px;
}
.personal-item label {
  display: flex; align-items: flex-start; gap: 10px; flex: 1;
}
.personal-item input[type="checkbox"] {
  width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px;
  accent-color: var(--teal);
}
.personal-texto {
  font-size: 14px; flex: 1; outline: none;
  border-radius: 6px; padding: 0 4px;
  min-width: 0; word-break: break-word;
}
.personal-texto[contenteditable="true"]:focus {
  background: #fff; box-shadow: 0 0 0 2px var(--teal);
}
.personal-item.done .personal-texto { text-decoration: line-through; color: var(--muted); }

.btn-add-personal {
  width: 100%; padding: 11px; border-radius: 12px; margin-top: 4px;
  background: none; border: 2px dashed var(--border); color: var(--teal);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-add-personal:hover { background: #f0fdf9; border-color: var(--teal); }

/* ─── Perfil ──────────────────────────────────────────────────────────────── */
.section-title {
  font-size: 12px; font-weight: 700; letter-spacing: .06em;
  color: var(--teal); text-transform: uppercase;
  margin: 20px 0 10px;
}
.perfil-field {
  display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px;
}
.perfil-field label { font-size: 13px; font-weight: 600; color: var(--navy); }

.etapa-info {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.etapa-box {
  flex: 1; background: var(--bg); border-radius: 14px;
  padding: 14px; border: 1.5px solid var(--border);
  text-align: center;
}
.etapa-box .etapa-icon { width: 36px; height: 36px; object-fit: contain; margin-bottom: 6px; display: block; margin-left: auto; margin-right: auto; }
.etapa-box .etapa-name { font-size: 13px; font-weight: 700; color: var(--navy); }
.etapa-box .etapa-date { font-size: 12px; color: var(--muted); margin-top: 4px; }
.etapa-box.active { border-color: var(--teal); background: #f0fdf9; box-shadow: 0 0 0 2px #11743a33; }

/* ─── Especialidades ──────────────────────────────────────────────────────── */
.esp-card {
  background: var(--surface); border-radius: 14px;
  padding: 14px; margin-bottom: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.esp-card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
}
.esp-nombre { font-size: 15px; font-weight: 700; color: var(--navy); }
.esp-monitor { font-size: 12px; color: var(--muted); margin-top: 2px; }
.esp-fechas  { font-size: 12px; color: var(--muted); margin-top: 4px; }
.badge-completada {
  font-size: 11px; background: #dcfce7; color: #166534;
  border-radius: 20px; padding: 2px 10px; font-weight: 700; flex-shrink: 0;
}
.badge-en-curso {
  font-size: 11px; background: #fef9c3; color: #854d0e;
  border-radius: 20px; padding: 2px 10px; font-weight: 700; flex-shrink: 0;
}

.fab {
  position: fixed; bottom: 80px; right: 16px; z-index: 30;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--teal); color: #fff;
  border: none; font-size: 24px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(14,159,159,.4);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
.fab:active { transform: scale(.92); }

/* ─── Calendario ──────────────────────────────────────────────────────────── */
.mes-label {
  font-size: 13px; font-weight: 700; color: var(--teal);
  letter-spacing: .04em; text-transform: uppercase;
  margin: 16px 0 8px;
}
.evento-item {
  display: flex; gap: 12px; padding: 12px 14px;
  background: var(--surface); border-radius: 14px;
  border: 1px solid var(--border); margin-bottom: 8px;
  align-items: flex-start;
}
.evento-fecha-col {
  text-align: center; min-width: 36px; flex-shrink: 0;
}
.evento-dia   { font-size: 20px; font-weight: 800; color: var(--navy); line-height: 1; }
.evento-mes   { font-size: 10px; color: var(--muted); text-transform: uppercase; }
.evento-info  { flex: 1; }
.evento-titulo { font-size: 14px; font-weight: 600; }
.evento-desc   { font-size: 12px; color: var(--muted); margin-top: 2px; }
.evento-tipo-badge {
  font-size: 10px; border-radius: 20px; padding: 2px 8px;
  font-weight: 700; margin-top: 4px; display: inline-block;
}
.tipo-campamento  { background: #ffe4e6; color: #9f1239; }
.tipo-excursion   { background: #dcfce7; color: #166534; }
.tipo-reunion     { background: #e0f2fe; color: #075985; }
.tipo-actividad   { background: #fef9c3; color: #854d0e; }
.tipo-otro        { background: #f3f4f6; color: #374151; }

.evento-salida    { border-left: 3px solid #0369a1; }
.evento-compartido { border-left: 3px solid #d97706; }

.add-evento-form {
  background: var(--surface); border-radius: 16px;
  padding: 16px; border: 1.5px dashed var(--teal); margin-bottom: 14px;
}
.add-evento-form h3 {
  font-size: 14px; font-weight: 700; color: var(--navy); margin: 0 0 12px;
}

/* ─── Inspiración ─────────────────────────────────────────────────────────── */
.cita-card {
  border-radius: 14px; padding: 16px; margin-bottom: 10px; color: #fff;
}
.cita-texto { font-size: 14px; font-style: italic; line-height: 1.5; margin: 0 0 8px; }
.cita-autora { font-size: 12px; font-weight: 700; }
.cita-rol    { font-size: 11px; opacity: .8; }

.ley-promesa-card {
  border-radius: 16px; overflow: hidden; margin-bottom: 12px;
}
.ley-card   { background: #fef08a; padding: 20px 16px; }
.prom-card  { background: #f9a8d4; padding: 20px 16px; }
.ley-card h2, .prom-card h2 {
  font-size: 18px; font-weight: 800; text-align: center;
  margin: 0 0 12px; color: var(--navy);
}
.ley-card p, .prom-card p {
  font-size: 14px; line-height: 1.6; text-align: center;
  margin: 0; color: var(--navy);
}

/* ─── Vista dirigente: mis scouts ───────────────────────────────────────────── */
.guia-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--surface);
  border-radius: 14px; margin-bottom: 8px;
  border: 1px solid var(--border);
  cursor: pointer; transition: background .15s;
}
.guia-item:hover { background: #f0fdf9; }
.guia-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--teal); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; flex-shrink: 0;
}
.guia-nombre { font-size: 14px; font-weight: 600; }
.guia-etapa  { font-size: 12px; color: var(--muted); }
.guia-patrulla { font-size: 11px; color: var(--muted); }

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

.divider {
  border: none; border-top: 1px solid var(--border);
  margin: 14px 0;
}

.row { display: flex; gap: 10px; }
.row .input-field { flex: 1; }

/* ─── Sellos de los territorios ──────────────────────────────────────────────
   El reconocimiento tras el consenso con el dirigente: "producido el acuerdo
   (...) se pegará un sello en la parte correspondiente al objetivo respectivo"
   (Manual de la Rama Scouts, p. 241). Los sellos oficiales son de papel — se
   imprimen, recortan y pegan —, así que aquí se imitan: pegados un poco
   torcidos, como quedaría uno de verdad.

   No es un visto bueno ni una corrección: si hay desacuerdo manda la opinión
   del scout. Por eso no lleva check ni color de "aprobado". */
.desafio-sello {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  margin-left: auto;
  align-self: center;
  object-fit: contain;
  transform: rotate(-7deg);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.22));
  animation: sello-aparece .45s cubic-bezier(.34,1.56,.64,1);
}

@keyframes sello-aparece {
  from { transform: rotate(-24deg) scale(1.7); opacity: 0; }
  to   { transform: rotate(-7deg)  scale(1);   opacity: 1; }
}

/* A quien prefiera no ver movimiento, no se lo imponemos. */
@media (prefers-reduced-motion: reduce) {
  .desafio-sello { animation: none; }
}

.t-sellos {
  font-size: 11px;
  color: rgba(255,255,255,.9);
  margin-top: 2px;
}

/* ─── Trébol «¿Cómo voy?» ─────────────────────────────────────────────────── */
.trebol-card { text-align: center; }
.trebol-titulo { font-size: 18px; font-weight: 800; color: var(--navy); margin-bottom: 4px; }
.trebol { width: 100%; max-width: 420px; height: auto; display: block; margin: 0 auto; }
.trebol-resumen { font-size: 14px; color: var(--text); line-height: 1.5; margin: 8px 0 14px; }

.compartir-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .6);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.compartir-panel {
  background: var(--surface); border-radius: 16px;
  padding: 16px; width: 100%; max-width: 360px;
  max-height: 100%; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
}
.compartir-preview {
  width: 100%; max-height: 55vh; object-fit: contain;
  border-radius: 10px; border: 1px solid var(--border);
}
.compartir-nota { font-size: 13px; color: var(--muted); margin: 0; text-align: center; }
.compartir-guardar { text-align: center; text-decoration: none; }

/* Enlace a la ayuda (soyscout.cl/ayuda) bajo el formulario de ingreso */
.login-ayuda { display: block; margin-top: 18px; text-align: center; font-size: 13px; color: rgba(255,255,255,.85); }
