/* DIAADIA — estilos del formulario de compartir. Objetivos grandes, secciones claras. */

.back { text-decoration: none; color: inherit; font-weight: 600; }

#report-form { padding: 8px 16px 96px; } /* bottom space for sticky bar */

/* --- Progress (Part X of 3) --- */
.progress {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}
.progress-text { font-size: 0.95rem; color: var(--text-soft); }
.progress-text strong { color: var(--c-action); }
.dots { display: flex; gap: 8px; margin-top: 8px; }
.dot { flex: 1; height: 6px; border-radius: 999px; background: var(--border); }
.dot.active { background: var(--c-action); }

/* --- Wizard parts --- */
.part { display: none; }
.part.active { display: block; }

/* --- Single-tap chips --- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: var(--tap-min); padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 999px; cursor: pointer;
  background: var(--surface);
}
.chip input { width: 18px; height: 18px; flex: none; }
.chip[data-checked="true"] {
  border-color: var(--c-action);
  background: color-mix(in srgb, var(--c-action) 10%, var(--surface));
}

/* --- Nav bar (Back / Next / Submit) --- */
.nav-bar { display: flex; gap: 12px; }
.nav-bar .btn { width: auto; flex: 1; }
.nav-bar #btn-back { flex: 0 0 38%; }

.fsec {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.fsec h2 {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.1rem; margin: 0 0 6px;
}
.step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--c-action); color: var(--c-action-ink);
  font-size: 0.9rem; flex: none;
}

.field-label { display: block; margin: 14px 0 6px; font-weight: 600; }

.text-input {
  width: 100%; min-height: var(--tap-min);
  padding: 12px; font: inherit;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
}
textarea.text-input { min-height: 84px; resize: vertical; }

/* Photo */
.photo-preview {
  display: block; width: 100%; max-height: 260px; object-fit: cover;
  margin-top: 12px; border-radius: var(--radius); border: 1px solid var(--border);
}

/* Map */
.map {
  height: 280px; width: 100%;
  border-radius: var(--radius); border: 1px solid var(--border);
  overflow: hidden; z-index: 0;
}
.locate-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--text);
  border: 2px solid rgba(0,0,0,0.2); border-radius: 6px;
  cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.locate-btn svg { display: block; }

/* Tarjetas de tipo de entrada: color + icono + texto (nunca color solo) */
.damage-grid { display: grid; gap: 10px; }
.damage-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; cursor: pointer;
  background: var(--surface);
  border: 2px solid var(--border); border-radius: var(--radius);
}
.damage-card input { width: 22px; height: 22px; flex: none; }
.damage-card .d-ico { display: inline-flex; flex: none; color: var(--text-soft); }
.damage-card.type-problema .d-ico { color: var(--c-problema); }
.damage-card.type-alegria .d-ico { color: var(--c-alegria); }
.damage-card.type-anhelo .d-ico { color: var(--c-anhelo); }
.damage-card .d-title { font-weight: 700; }
.damage-card .d-desc { font-size: 0.85rem; color: var(--text-soft); }
.damage-card[data-checked="true"] { border-color: var(--c-action); background: color-mix(in srgb, var(--c-action) 8%, var(--surface)); }
.damage-card.type-problema[data-checked="true"] { border-color: var(--c-problema); }
.damage-card.type-alegria[data-checked="true"] { border-color: var(--c-alegria); }
.damage-card.type-anhelo[data-checked="true"] { border-color: var(--c-anhelo); }

/* Checkbox / radio lists */
.check-list { display: grid; gap: 4px; }
.check-list label, .seg label {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--tap-min); padding: 8px 10px;
  border-radius: var(--radius); cursor: pointer;
}
.check-list label:hover { background: var(--bg-soft); }
.check-list input { width: 20px; height: 20px; flex: none; }
.group-label { font-weight: 700; margin: 12px 0 2px; color: var(--text-soft); font-size: 0.85rem; text-transform: uppercase; letter-spacing: .04em; }

.seg { display: flex; gap: 10px; }
.seg--col { flex-direction: column; }
.seg--col label { justify-content: flex-start; }
.seg label { border: 1px solid var(--border); flex: 1; justify-content: center; }

/* Sticky submit bar — floats inside the attention frame so the blue buttons
   never sit under the amber border. */
.submit-bar {
  position: sticky;
  bottom: 14px;
  margin: 0 14px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.18);
}

/* Anonymous updates opt-in + follow code */
.optin { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.follow-code {
  font-family: Consolas, monospace; font-size: 1.5rem; font-weight: 800; letter-spacing: 2px;
  color: var(--c-action); background: var(--bg-soft);
  border: 1px dashed var(--border); border-radius: 10px;
  padding: 12px; margin: 10px 0; user-select: all;
}

/* Follow ("Check my report") page */
.follow-input { display: flex; gap: 10px; margin: 12px 0 4px; }
.follow-input .text-input { flex: 1; }
.follow-input .btn { width: auto; flex: none; }
.timeline-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }

/* "My reports" list (saved on this device) */
.report-chip {
  display: flex; align-items: center; gap: 8px; width: 100%;
  min-height: var(--tap-min); padding: 10px 12px; margin: 6px 0;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; font: inherit; text-align: start;
}
.report-chip:hover { background: var(--bg-soft); }
.report-chip .mono { font-family: Consolas, monospace; font-weight: 700; }

/* Confirmation overlay: si la tarjeta no cabe (pantallas bajas), se desplaza
   en vez de cortarse; margin:auto la centra cuando sí cabe. */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding:
    calc(16px + env(safe-area-inset-top, 0px))
    calc(16px + env(safe-area-inset-right, 0px))
    calc(16px + env(safe-area-inset-bottom, 0px))
    calc(16px + env(safe-area-inset-left, 0px));
  overflow-y: auto; z-index: 1000;
}
.overlay-card {
  background: var(--surface); color: var(--text);
  border-radius: 16px; padding: clamp(16px, 3.5vh, 28px); text-align: center;
  max-width: 360px; width: 100%; margin: auto;
}
.optin-error { color: var(--c-critical); font-size: 0.9em; margin: 8px 0 0; }
.big-icon { font-size: 3rem; }

/* ============================================================
   Modo "fit": el wizard cabe SIEMPRE en una pantalla, sin scroll.
   Los 4 lados del marco arcoíris quedan visibles y nada se corta:
   la tipografía y los espacios escalan con la altura del viewport.
   ============================================================ */
body.fit {
  height: 100vh;   /* respaldo para navegadores sin dvh */
  height: 100dvh;
  overflow: hidden;
  /* tipografía fluida: escala con la altura disponible */
  font-size: clamp(13px, 2.1vh, 17px);
}
body.fit .app {
  /* Anclada al MISMO rectángulo que el marco (position: fixed): con 100dvh, en
     Android la altura no coincidía con la ventana visible y la barra inferior
     quedaba ~50 px más abajo, cortada por el marco. */
  position: fixed;
  inset: 0;
  margin: 0 auto;
  height: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  /* despeje del marco arcoíris (inset 6px + anillo 4px) y de las zonas del
     sistema: con viewport-fit=cover, Chrome en Android (135+) e iOS dibujan la
     página detrás de las barras del sistema. */
  padding:
    calc(12px + env(safe-area-inset-top, 0px))
    calc(12px + env(safe-area-inset-right, 0px))
    calc(16px + env(safe-area-inset-bottom, 0px))
    calc(12px + env(safe-area-inset-left, 0px));
}
/* En modo fit no hay scroll, así que sticky no la separa del borde: la barra
   va al final del flujo, con aire propio, siempre dentro del marco. */
body.fit .submit-bar {
  position: static;
  flex: none;
  margin: clamp(4px, 1vh, 10px) 8px 0;
  padding: clamp(6px, 1.2vh, 12px);
}
body.fit .topbar { padding: 0 8px; flex: none; min-height: 34px; }
body.fit .progress {
  position: static; flex: none;
  background: transparent; border-bottom: none;
  padding: clamp(1px, 0.5vh, 6px) 8px;
}
body.fit .progress-text { font-size: 0.85em; }
body.fit .dots { margin-top: clamp(3px, 0.7vh, 8px); }
body.fit .dot { height: 5px; }

body.fit #report-form {
  flex: 1;
  min-height: 0;
  padding: 0 8px;
  overflow: hidden;
  display: flex;
}
body.fit .part { width: 100%; }
body.fit .part.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Si el paso no cabe (pantallas bajas), se desplaza en vez de cortarse. */
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* Sombras que indican que hay más contenido arriba o abajo (solo aparecen
     cuando efectivamente hay scroll: técnica de fondos "local" + "scroll"). */
  background:
    linear-gradient(var(--bg) 30%, transparent) center top / 100% 28px no-repeat local,
    linear-gradient(transparent, var(--bg) 70%) center bottom / 100% 28px no-repeat local,
    radial-gradient(farthest-side at 50% 0, rgba(0, 0, 0, .22), transparent) center top / 100% 12px no-repeat scroll,
    radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, .22), transparent) center bottom / 100% 12px no-repeat scroll;
}
/* Reparte el espacio libre entre las secciones cuando sobra (como antes con
   space-evenly), pero sin empujar contenido fuera del alcance del scroll. */
body.fit .part.active > * { margin-block: auto; }
body.fit .fsec {
  flex: none;
  padding: clamp(2px, 0.8vh, 10px) 0;
  border-bottom: none;
}
body.fit .fsec h2 { font-size: clamp(0.9rem, 2.2vh, 1.05rem); margin: 0 0 clamp(2px, 0.6vh, 6px); }
body.fit .muted { font-size: 0.85em; margin: 0 0 clamp(3px, 0.8vh, 8px); }

/* Tarjetas de tipo compactas */
body.fit .damage-grid { gap: clamp(4px, 0.8vh, 8px); }
body.fit .damage-card { padding: clamp(4px, 1vh, 10px) clamp(8px, 1.3vh, 14px); gap: 10px; }
body.fit .damage-card input { width: 18px; height: 18px; }
body.fit .damage-card .d-desc { font-size: 0.78em; line-height: 1.25; display: block; margin-top: 1px; }
body.fit .damage-card .d-title { font-size: 0.95em; }

/* Escala de importancia: 5 chips numéricos en una sola fila + etiqueta debajo */
.chips--intensity .chip { justify-content: center; min-width: 52px; }
.int-caption { margin: 4px 0 0; font-size: 0.85em; color: var(--text-soft); font-weight: 600; }

/* Chips compactos: la selección se ve por borde + fondo + negrita */
body.fit .chips { gap: clamp(4px, 0.8vh, 8px); }
body.fit .chip {
  min-height: clamp(24px, 3.6vh, 40px);
  padding: clamp(2px, 0.5vh, 6px) clamp(8px, 1.4vh, 13px);
  font-size: clamp(0.74rem, 1.8vh, 0.95rem);
}
body.fit .chip input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
body.fit .chip[data-checked="true"] { font-weight: 700; }

/* Paso 2: textarea y foto acotados a la altura disponible */
body.fit textarea.text-input { min-height: 0; height: clamp(56px, 13vh, 140px); resize: none; }
body.fit .photo-preview { max-height: 14vh; margin-top: clamp(4px, 1vh, 12px); }
body.fit #ai-note { margin-top: clamp(4px, 1vh, 10px); font-size: 0.85em; }

/* Paso 3: opciones de ubicación y mapa acotado */
body.fit .seg--col { gap: clamp(4px, 0.9vh, 10px); }
body.fit .seg label { min-height: clamp(30px, 4.5vh, 44px); padding: clamp(3px, 0.7vh, 8px) 10px; }
body.fit .map { height: clamp(110px, 24vh, 260px); }
body.fit #loc-status { margin-top: clamp(4px, 0.9vh, 8px); font-size: 0.85em; }

/* Inputs y barra de navegación dentro del flujo (no sticky) */
body.fit .text-input { min-height: clamp(32px, 4.6vh, 44px); padding: clamp(6px, 1vh, 12px); }
body.fit .submit-bar {
  position: static;
  flex: none;
  margin: clamp(3px, 0.8vh, 8px) 8px 14px;
  padding: clamp(5px, 1vh, 10px);
}
body.fit .btn { min-height: clamp(34px, 4.6vh, 46px); padding: clamp(5px, 0.9vh, 10px) 16px; }

/* Pantallas muy bajas: se ocultan las descripciones secundarias
   antes de permitir que algo se corte. */
@media (max-height: 660px) {
  body.fit .damage-card .d-desc { display: none; }
  body.fit .muted { display: none; }
}
