/* ==========================================================================
   Cuestionarios Berny — estilos compartidos (views/login_index.php y views/answer.php)
   Mobile-first. Convive con Bootstrap 3.3.7 (se carga antes) y NO cambia ids/clases que usa el JS.
   ========================================================================== */
:root {
  --cq-ink: #1d2430;
  --cq-muted: #667085;
  --cq-line: #e3e8ef;
  --cq-bg: #f3f5f8;
  --cq-card: #ffffff;
  --cq-dark: #141414;
  --cq-accent: #f37e2b;
  --cq-accent-dark: #d96a1a;
  --cq-ok: #1f9d55;
  --cq-warn: #d98a00;
  --cq-danger: #d92d20;
  --cq-radius: 14px;
  --cq-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
}

html { -webkit-text-size-adjust: 100%; font-size: 16px; } /* Bootstrap 3 fija html{font-size:10px}: sin esto los rem salen chiquitos */
body.cq {
  margin: 0;
  padding: 0 0 env(safe-area-inset-bottom);
  background: var(--cq-bg);
  color: var(--cq-ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
.cq *, .cq *::before, .cq *::after { box-sizing: border-box; }
.cq label { display: inline-block; max-width: 100%; margin: 0; font-weight: normal; }

/* ---- Barra superior ---- */
.cq-top {
  background: var(--cq-dark);
  color: #fff;
  padding-top: env(safe-area-inset-top);
  position: relative;
}
.cq-top::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--cq-accent); }
.cq-top-in {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 60px; padding-top: 8px; padding-bottom: 8px;
}
.cq-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cq-brand img { height: 36px; width: auto; max-width: 120px; border-radius: 6px; background: #fff; padding: 3px 6px; flex: 0 0 auto; }
.cq-brand span { font-size: 1.05rem; font-weight: 600; letter-spacing: .2px; white-space: nowrap; }
.cq-user { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cq-user-mail { font-size: .85rem; color: #c7ccd4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.cq-exit {
  display: inline-block; padding: 8px 16px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px;
  color: #fff !important; font-size: .9rem; line-height: 1.2; text-decoration: none !important; background: transparent;
  min-height: 40px; display: inline-flex; align-items: center;
}
.cq-exit:hover, .cq-exit:focus { background: rgba(255,255,255,.12); }

/* ---- Contenedor ---- */
.cq-wrap { width: 100%; max-width: 980px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }

/* ---- Encabezado del cuestionario ---- */
.cq-hero { padding: 22px 0 6px; }
.cq-hero h1 { margin: 0; font-size: 1.55rem; line-height: 1.25; font-weight: 700; color: var(--cq-ink); }
.cq-hero p { margin: 4px 0 0; color: var(--cq-muted); font-size: .98rem; }

/* ---- Datos del cuestionario ---- */
.cq-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 14px 0 6px; }
.cq-stat { background: var(--cq-card); border: 1px solid var(--cq-line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--cq-shadow); min-width: 0; }
.cq-stat-label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; color: var(--cq-muted); font-weight: 600; }
.cq-stat-value { display: block; margin-top: 2px; font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; word-break: break-word; }
.cq-stat-sub { display: block; font-size: .8rem; color: var(--cq-muted); font-variant-numeric: tabular-nums; }
.cq-details { margin: 6px 0 0; font-size: .82rem; color: var(--cq-muted); }
.cq-details summary { cursor: pointer; padding: 6px 0; list-style: none; }
.cq-details summary::-webkit-details-marker { display: none; }
.cq-details summary::before { content: "▸ "; }
.cq-details[open] summary::before { content: "▾ "; }
.cq-details dl { margin: 4px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; }
.cq-details dt { font-weight: 600; }
.cq-details dd { margin: 0; font-variant-numeric: tabular-nums; word-break: break-word; }

/* ---- Estado: sin cuestionario ---- */
.cq-empty {
  background: var(--cq-card); border: 1px solid var(--cq-line); border-radius: var(--cq-radius); box-shadow: var(--cq-shadow);
  margin: 28px auto; padding: 32px 22px; max-width: 560px; text-align: center; color: var(--cq-ink);
}
.cq-empty img { display: block; margin: 0 auto 14px; width: 96px; height: 96px; border-radius: 50%; object-fit: cover; opacity: .9; }
.cq-empty .cq-empty-title { font-size: 1.2rem; font-weight: 700; margin: 0 0 6px; }
.cq-empty .cq-empty-text { color: var(--cq-muted); margin: 0; }
.cq-empty .cq-empty-text label { display: block; margin-top: 8px; }

/* ---- Tarjeta de pregunta ---- */
.cq-stage { padding-top: 14px; padding-bottom: 28px; }
.cq-card {
  background: var(--cq-card); border: 1px solid var(--cq-line); border-radius: var(--cq-radius);
  box-shadow: var(--cq-shadow); padding: 22px; margin: 0 0 18px;
}
.cq-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cq-badge { background: #fff3e8; color: var(--cq-accent-dark); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; padding: 3px 10px; border-radius: 999px; }
.cq-qid { color: var(--cq-muted); font-size: .8rem; font-variant-numeric: tabular-nums; }
.cq-qtext { margin: 0 0 18px; font-size: 1.3rem; line-height: 1.4; font-weight: 600; color: var(--cq-ink); word-break: break-word; }
.cq-qbody { display: flex; flex-direction: column; }
.cq-qbody > .cq-timer { order: -1; }

/* ---- Temporizador de la pregunta ---- */
.cq-timer {
  background: #f8fafc; border: 1px solid var(--cq-line); border-radius: 12px; padding: 12px 14px; margin: 0 0 16px;
  transition: background-color .3s, border-color .3s;
}
.cq-timer:empty { display: none; }
.cq-timer-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.cq-timer-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .6px; color: var(--cq-muted); font-weight: 600; }
.cq-timer-value { font-size: 1.9rem; line-height: 1.1; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--cq-ink); }
.cq-bar { height: 6px; border-radius: 999px; background: #e6ebf1; overflow: hidden; margin-top: 8px; }
.cq-bar-fill { height: 100%; width: 100%; background: var(--cq-ok); border-radius: 999px; transition: width 1s linear, background-color .3s; }
.cq-timer-note { margin-top: 6px; font-size: .78rem; color: var(--cq-muted); }
.cq-timer.is-warn { background: #fffaeb; border-color: #fedf89; }
.cq-timer.is-warn .cq-bar-fill { background: var(--cq-warn); }
.cq-timer.is-danger { background: #fef3f2; border-color: #fecdca; }
.cq-timer.is-danger .cq-timer-value { color: var(--cq-danger); }
.cq-timer.is-danger .cq-bar-fill { background: var(--cq-danger); }

/* ---- Respuesta y botones ---- */
.cq-answer { margin: 0 0 14px; }
.cq-qbody input.form-control, .cq-qbody .cq-input {
  height: 54px; padding: 10px 14px; font-size: 16px; /* 16px evita el zoom automatico en iPhone */
  border: 1.5px solid #cfd6df; border-radius: 10px; box-shadow: none; background: #fff; color: var(--cq-ink);
}
.cq-qbody input.form-control:focus { border-color: var(--cq-accent); box-shadow: 0 0 0 3px rgba(243,126,43,.22); outline: 0; }
.cq-qbody input.form-control[disabled] { background: #f1f4f8; cursor: not-allowed; }
.cq-field { margin: 0 0 10px; }
.cq-field-label { display: block; margin-bottom: 4px; font-size: .9rem; color: var(--cq-muted); }
.cq-option {
  display: flex !important; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; margin: 0 0 8px !important;
  border: 1.5px solid #cfd6df; border-radius: 10px; background: #fff; cursor: pointer; min-height: 48px;
}
.cq-option input { margin: 0; width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--cq-accent); }
.cq-option:hover { border-color: var(--cq-accent); }
.cq-actions { display: flex; justify-content: flex-end; }
.cq-btn, input.cq-btn, .btn.cq-btn {
  background: var(--cq-accent); border: 0; color: #fff; font-weight: 600; font-size: 1rem;
  min-height: 52px; padding: 12px 34px; border-radius: 10px; cursor: pointer; transition: background-color .15s, transform .05s;
}
.cq-btn:hover, .cq-btn:focus { background: var(--cq-accent-dark); color: #fff; outline: 0; }
.cq-btn:active { transform: translateY(1px); }
.cq-btn:focus-visible, .cq-exit:focus-visible, .cq-details summary:focus-visible { outline: 3px solid rgba(243,126,43,.55); outline-offset: 2px; }

/* ---- Datos internos que lee el JS (no se muestran) ---- */
.cq-data { display: none !important; }

/* ---- Cargando ---- */
.cq-loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--cq-muted); padding: 30px 0; }
.cq-loading::before { content: ""; width: 20px; height: 20px; border: 3px solid #d5dbe3; border-top-color: var(--cq-accent); border-radius: 50%; animation: cq-spin .8s linear infinite; }
#contenido:not(:empty) + .cq-loading { display: none; }
@keyframes cq-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .cq-loading::before { animation: none; } .cq-bar-fill { transition: none; } }

.cq-foot { text-align: center; color: var(--cq-muted); font-size: .8rem; padding: 4px 0 24px; }
.cq-foot a { color: var(--cq-muted); text-decoration: underline; }

/* ---- Clases antiguas que aun usa el texto de "proximo cuestionario" ---- */
.font_naranja { color: var(--cq-danger); }
.font_azul { color: #1d4ed8; }
.font_gris { color: var(--cq-muted); }
.font_gris2 { color: #98a2b3; }

/* ==========================================================================
   Celulares y tabletas chicas
   ========================================================================== */
@media (max-width: 767px) {
  .cq-top-in { min-height: 54px; }
  .cq-brand img { height: 30px; }
  .cq-brand span { font-size: 1rem; }
  .cq-user-mail { display: none; }               /* el correo va en "Detalles" */
  .cq-hero { padding-top: 16px; }
  .cq-hero h1 { font-size: 1.3rem; }
  .cq-meta { grid-template-columns: 1fr 1fr; gap: 10px; }
  .cq-stat { padding: 10px 12px; }
  .cq-stat-value { font-size: 1.02rem; }
  .cq-stat.cq-stat-wide { grid-column: 1 / -1; }
  .cq-card { padding: 16px; border-radius: 12px; }
  .cq-qtext { font-size: 1.18rem; margin-bottom: 14px; }
  /* El tiempo queda siempre visible mientras se escribe (el teclado ocupa media pantalla) */
  .cq-qbody > .cq-timer { position: sticky; top: 0; z-index: 20; margin-left: -4px; margin-right: -4px; box-shadow: 0 6px 14px rgba(16,24,40,.08); }
  .cq-timer-value { font-size: 1.7rem; }
  .cq-actions { justify-content: stretch; }
  .cq-actions input, .cq-actions .cq-btn { width: 100%; }
  .cq-empty { margin: 18px 0; padding: 24px 16px; }
}
@media (max-width: 380px) {
  .cq-wrap { padding-left: 12px; padding-right: 12px; }
  .cq-stat-value { font-size: .98rem; }
}

/* ==========================================================================
   Estados: sin cuestionario y "Gracias por participar" (certificado)
   ========================================================================== */
.cq-empty-sub { color: var(--cq-muted); margin: 0 0 16px; }
.cq-empty-text { text-align: center; }
.cq-empty-text label { display: block; margin-top: 10px; }
.cq-empty-text .cq-sub { font-size: .78rem; color: var(--cq-muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.cq-list {
  text-align: left; margin-top: 6px; background: #f8fafc; border: 1px solid var(--cq-line); border-radius: 10px;
  padding: 10px 12px; font-size: .88rem; color: var(--cq-ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.cq-done { max-width: 640px; }
.cq-cert { text-align: center; border: 1px dashed #cfd6df; border-radius: 12px; padding: 18px 14px; background: #fcfcfd; }
.cq-cert h4, .cq-cert h5, .cq-cert h6 { margin: 6px 0; font-weight: 600; }
.cq-cert h4 { font-size: .9rem; color: var(--cq-muted); text-transform: uppercase; letter-spacing: .6px; }
.cq-cert span[style*="font-size:80px"] { font-size: 3.4rem !important; font-weight: 700; line-height: 1.1; color: var(--cq-ink); }
.cq-cert span[style*="color:#F00"] { color: var(--cq-muted) !important; }
.cq-cert table { margin: 10px auto; }
.cq-cert table td { vertical-align: middle; padding: 0 10px; text-align: left; }
.cq-cert table img { width: 64px; height: 64px; }
.cq-cert a[onclick] {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; padding: 10px 18px; background: #fff;
  border: 1.5px solid #cfd6df; border-radius: 10px; color: var(--cq-ink); text-decoration: none; cursor: pointer; min-height: 44px;
}
.cq-cert a[onclick]:hover { border-color: var(--cq-accent); }
.cq-cert a[onclick] br { display: none; }
@media print { .cq-top, .cq-exit, .cq-cert a[onclick] { display: none !important; } body.cq { background: #fff; } }

/* ==========================================================================
   Login (views/login_index.php) — solo el logo de Berny
   ========================================================================== */
body.cq-login-page {
  min-height: 100vh;
  background: var(--cq-dark);
  background-image: radial-gradient(1200px 500px at 50% -10%, #2a2a2a 0%, rgba(20,20,20,0) 70%);
}
.cq-login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
.cq-login-card {
  width: 100%; max-width: 420px; background: var(--cq-card); border-radius: 18px; padding: 32px 28px 28px;
  box-shadow: 0 10px 40px rgba(0,0,0,.45); position: relative; overflow: hidden;
}
.cq-login-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--cq-accent); }
.cq-login-logo { display: block; margin: 0 auto 18px; width: 190px; max-width: 70%; height: auto; }
.cq-login-card h1 { margin: 0; text-align: center; font-size: 1.45rem; font-weight: 700; color: var(--cq-ink); }
.cq-login-sub { margin: 6px 0 22px; text-align: center; color: var(--cq-muted); font-size: .95rem; }
.cq-alert {
  margin: 0 0 16px; padding: 11px 14px; border-radius: 10px; font-size: .92rem;
  background: #fef3f2; border: 1px solid #fecdca; color: #b42318;
}
.cq-field-group { margin: 0 0 16px; }
.cq-field-group label { display: block; margin: 0 0 6px; font-size: .85rem; font-weight: 600; color: var(--cq-ink); }
.cq-login-card input[type="text"], .cq-login-card input[type="password"] {
  display: block; width: 100%; height: 52px; padding: 10px 14px; font: inherit; font-size: 16px; /* 16px: sin zoom en iPhone */
  color: var(--cq-ink); background: #fff; border: 1.5px solid #cfd6df; border-radius: 10px; box-shadow: none;
  -webkit-appearance: none; appearance: none;
}
.cq-login-card input:focus { border-color: var(--cq-accent); box-shadow: 0 0 0 3px rgba(243,126,43,.22); outline: 0; }
.cq-pass { position: relative; }
.cq-pass input { padding-right: 86px !important; }
.cq-pass-toggle {
  position: absolute; top: 6px; right: 6px; height: 40px; padding: 0 12px; border: 0; border-radius: 8px;
  background: transparent; color: var(--cq-accent-dark); font-weight: 600; font-size: .88rem; cursor: pointer;
}
.cq-pass-toggle:hover, .cq-pass-toggle:focus-visible { background: #fff3e8; outline: 0; }
.cq-login-btn { display: block; width: 100%; margin-top: 8px; }
.cq-login-btn[disabled] { opacity: .7; cursor: wait; }
@media (max-width: 480px) {
  .cq-login-card { padding: 26px 20px 22px; border-radius: 16px; }
  .cq-login-logo { width: 170px; }
}
