/* ============================================================
   Encuesta JCV · App encuestadora — diseño premium mobile-first
   ============================================================ */
:root {
  --ink: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --bg: #eef2f7;
  --card: #ffffff;
  --line: #e2e8f0;

  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --primary-ring: rgba(79, 70, 229, .32);

  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 10px 30px rgba(15, 23, 42, .07);
  --shadow-btn: 0 8px 20px rgba(79, 70, 229, .35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .9rem; }

/* ---------- banner offline ---------- */
.net-banner {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: .5rem; justify-content: center;
  background: linear-gradient(90deg, #b45309, #d97706);
  color: #fff; font-size: .82rem; font-weight: 600;
  padding: .45rem 1rem .45rem .5rem;
}
.net-banner svg { width: 15px; height: 15px; flex: none; }

/* ---------- vistas ---------- */
.view { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- login ---------- */
.login-wrap {
  flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 2rem 1.25rem; gap: 1.5rem;
  background:
    radial-gradient(1000px 500px at 50% -10%, rgba(124, 58, 237, .18), transparent 60%),
    radial-gradient(700px 400px at 90% 110%, rgba(79, 70, 229, .12), transparent 55%);
}
.brand { text-align: center; }
.brand-logo {
  width: 84px; height: 84px; margin: 0 auto 1rem; border-radius: 24px;
  box-shadow: var(--shadow-btn); overflow: hidden;
  background: linear-gradient(160deg, var(--primary), var(--primary-2));
}
.brand-logo img { width: 100%; height: 100%; display: block; }
.brand h1 { font-size: 1.6rem; letter-spacing: -.02em; }
.brand-sub { color: var(--muted); font-size: .92rem; margin-top: .3rem; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid rgba(226, 232, 240, .8);
}
.login-card { width: 100%; max-width: 400px; padding: 1.6rem 1.4rem; display: flex; flex-direction: column; gap: 1.1rem; }

.field { display: flex; flex-direction: column; gap: .45rem; }
.field span { font-size: .85rem; font-weight: 600; color: var(--ink); }
.field input, .field textarea {
  font: inherit; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: .8rem 1rem; background: #f8fafc; transition: border .15s, box-shadow .15s, background .15s;
  width: 100%;
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 4px var(--primary-ring);
}
.form-error { color: var(--danger); font-size: .86rem; font-weight: 600; text-align: center; }
.login-note { color: var(--muted-2); font-size: .8rem; text-align: center; line-height: 1.45; }
.app-version { color: var(--muted-2); font-size: .75rem; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  font: inherit; font-weight: 650; border: none; cursor: pointer; user-select: none;
  border-radius: 14px; padding: .85rem 1.3rem; font-size: 1rem;
  transition: transform .12s, box-shadow .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: var(--shadow-btn); }
.btn-outline { background: #fff; color: var(--primary-dark); border: 1.5px solid #c7d2fe; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-block { width: 100%; }
.btn-big { padding: 1.05rem 1.5rem; font-size: 1.08rem; border-radius: 16px; }

.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: none; background: #fff;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  color: var(--muted); box-shadow: var(--shadow); transition: transform .12s, color .15s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.light { background: rgba(255,255,255,.16); color: #fff; box-shadow: none; backdrop-filter: blur(6px); }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- home ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; padding-top: calc(1rem + env(safe-area-inset-top));
}
.topbar-user { display: flex; align-items: center; gap: .85rem; }
.avatar {
  width: 46px; height: 46px; border-radius: 14px; flex: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; font-weight: 700; font-size: 1.05rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-btn);
}
.hello { font-size: .8rem; color: var(--muted); }
.topbar h2 { font-size: 1.15rem; letter-spacing: -.01em; }

.page { width: 100%; max-width: 560px; margin: 0 auto; padding: 0 1.25rem 2.5rem; display: flex; flex-direction: column; gap: 1.1rem; }

.sync-card { padding: 1.25rem; display: flex; flex-direction: column; gap: .95rem; }
.sync-status { display: flex; align-items: center; gap: .5rem; font-size: .85rem; font-weight: 700; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,.18); }
.dot.off { background: #f59e0b; box-shadow: 0 0 0 4px rgba(245,158,11,.18); }
.sync-numbers { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.sync-item { display: flex; flex-direction: column; gap: .15rem; }
.sync-item strong { font-size: 1.7rem; letter-spacing: -.02em; }
.sync-item strong.warn-n { color: var(--warn); }
.sync-item span { font-size: .74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.sync-last { font-size: .78rem; color: var(--muted-2); text-align: center; }

.history-card { padding: 1.2rem; }
.history-card h3 { font-size: .95rem; margin-bottom: .8rem; }
.history-list { list-style: none; display: flex; flex-direction: column; gap: .55rem; }
.history-list li {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .7rem .9rem; border-radius: 12px; background: #f8fafc; border: 1px solid var(--line);
}
.hx-info { display: flex; flex-direction: column; }
.hx-title { font-size: .88rem; font-weight: 650; }
.hx-date { font-size: .74rem; color: var(--muted); }
.chip {
  font-size: .7rem; font-weight: 700; padding: .28rem .6rem; border-radius: 999px; white-space: nowrap;
}
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-pending { background: var(--warn-soft); color: var(--warn); }

/* ---------- encuesta ---------- */
#view-survey { background: var(--bg); }
.survey-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: .9rem;
  padding: .9rem 1.1rem;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary-2));
  color: #fff;
  padding-top: calc(.9rem + env(safe-area-inset-top));
}
.survey-progress { flex: 1; }
.survey-step-label { font-size: .78rem; font-weight: 600; opacity: .85; margin-bottom: .35rem; }
.progress-track { height: 7px; border-radius: 99px; background: rgba(255,255,255,.25); overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #a5b4fc, #fff);
  border-radius: 99px; transition: width .35s cubic-bezier(.4,0,.2,1);
}
.btn-cancel {
  background: rgba(255,255,255,.14); color: #fff; border: none; font: inherit;
  font-size: .8rem; font-weight: 700; padding: .5rem .8rem; border-radius: 10px; cursor: pointer;
}

.survey-nav {
  position: sticky; bottom: 0; z-index: 40;
  display: flex; gap: .8rem; padding: .9rem 1.25rem;
  background: linear-gradient(to top, var(--bg) 75%, transparent);
  padding-bottom: calc(.9rem + env(safe-area-inset-bottom));
}
.survey-nav .btn { flex: 1; }

/* preguntas */
.q-block { margin-bottom: 1.4rem; }
.q-text { font-size: 1.02rem; font-weight: 700; line-height: 1.4; margin-bottom: .2rem; }
.q-req { color: var(--primary); font-weight: 800; }
.q-opt-note { font-size: .78rem; color: var(--muted); margin-bottom: .75rem; }

.opt {
  display: flex; align-items: center; gap: .8rem;
  border: 1.5px solid var(--line); border-radius: 14px;
  background: #fff; padding: .85rem 1rem; margin-bottom: .6rem;
  cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s, transform .1s;
  min-height: 52px; position: relative;
}
.opt:active { transform: scale(.985); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .mark {
  width: 24px; height: 24px; flex: none; position: relative;
  border: 2px solid #cbd5e1; border-radius: 999px; background: #fff; transition: all .15s;
}
.opt.multiple .mark { border-radius: 7px; }
.opt .txt { font-size: .95rem; line-height: 1.35; }
.opt.selected {
  border-color: var(--primary); background: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.opt.selected .mark { border-color: var(--primary); background: var(--primary); }
.opt.selected .mark::after {
  content: ''; position: absolute; inset: 0;
  background: #fff;
}
.opt.single.selected .mark::after { margin: 6px; border-radius: 999px; }
.opt.multiple.selected .mark::after {
  margin: 4px; border-radius: 3px;
  clip-path: polygon(14% 44%, 0 65%, 40% 100%, 100% 16%, 80% 0%, 37% 62%);
}

.q-block.error .opt { border-color: #fecaca; }
.q-block.error .q-text { color: var(--danger); }
.q-error-msg { color: var(--danger); font-size: .8rem; font-weight: 600; margin-top: .4rem; }

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

.section-title {
  font-size: .8rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--primary-dark); margin: 1.2rem 0 .4rem;
}
.anon-note {
  display: flex; gap: .6rem; align-items: flex-start;
  background: var(--primary-soft); border: 1px solid #c7d2fe; color: #3730a3;
  border-radius: 12px; padding: .75rem .9rem; font-size: .82rem; line-height: 1.45;
  margin-bottom: 1.2rem;
}
.anon-note svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }

@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }
.q-block.error { animation: shake .3s; }

/* ---------- gracias ---------- */
.thanks-wrap {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1rem; padding: 2rem 1.5rem; text-align: center;
}
.check-anim { width: 110px; height: 110px; }
.ck-circle {
  stroke: var(--ok); stroke-width: 3;
  stroke-dasharray: 160; stroke-dashoffset: 160;
  animation: dash .55s ease-out forwards;
}
.ck-check {
  stroke: var(--ok); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40;
  animation: dash .4s .45s ease-out forwards;
}
@keyframes dash { to { stroke-dashoffset: 0; } }
.thanks-wrap h2 { font-size: 1.5rem; letter-spacing: -.02em; }
.thanks-sub { color: var(--muted); max-width: 340px; line-height: 1.5; }
.thanks-actions { display: flex; flex-direction: column; gap: .6rem; width: 100%; max-width: 340px; margin-top: .5rem; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(1.4rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: .88rem; font-weight: 600;
  padding: .8rem 1.3rem; border-radius: 14px; z-index: 100;
  box-shadow: 0 10px 30px rgba(15,23,42,.35); max-width: 92vw; text-align: center;
  animation: toast-in .25s ease-out;
}
.toast.ok { background: #065f46; }
.toast.err { background: #991b1b; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }

/* desktop */
@media (min-width: 700px) {
  .login-card { padding: 2rem; }
}
