/* ===== CamGeo — interfaz tipo cámara, oscura y a pantalla completa ===== */

:root {
  --bg: #0b0f14;
  --panel: #141b23;
  --line: #24313f;
  --text: #eaf1f8;
  --muted: #93a4b6;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --accent: #25d366;      /* verde WhatsApp: el destino habitual de la foto */
  --primary: #2f80ed;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  overflow: hidden;
}

/* ===== Barra superior ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(var(--safe-top) + 8px) 12px 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .2px;
  min-width: 0;
}
.chip__dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex: none;
  background: var(--muted);
}
.chip--wait .chip__dot { background: var(--bad); animation: pulse 1.2s infinite; }
.chip--poor .chip__dot { background: var(--warn); }
.chip--good .chip__dot { background: var(--ok); }
@keyframes pulse { 50% { opacity: .25; } }

#gps-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.icon-btn--lg { width: 54px; height: 54px; border-radius: 16px; }
.icon-btn--placeholder { visibility: hidden; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active { transform: scale(.94); }

.badge {
  position: absolute;
  top: -6px; right: -6px;
  min-width: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

/* ===== Escenario de la cámara ===== */
.stage {
  position: relative;
  min-height: 0;
  background: #000;
  display: grid;
  place-items: center;
  overflow: hidden;
}

/* 'contain' a propósito: lo que se ve en pantalla es exactamente lo que se guarda. */
#video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.blocker {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(11, 15, 20, .94);
}
.blocker__box {
  display: grid;
  gap: 12px;
  justify-items: center;
  max-width: 340px;
  text-align: center;
}
.blocker__icon { font-size: 40px; }
.blocker__box p { margin: 0; color: var(--muted); line-height: 1.5; }

/* ===== Controles ===== */
.controls {
  display: grid;
  gap: 10px;
  padding: 10px 14px calc(var(--safe-bottom) + 14px);
}

.note {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
}
.note::placeholder { color: var(--muted); }
.note:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.controls__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.shutter {
  width: 74px; height: 74px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, .85);
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.shutter span {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: #fff;
  transition: transform .12s ease;
}
.shutter:active span { transform: scale(.85); }
.shutter:disabled { opacity: .4; cursor: not-allowed; }

/* ===== Botones ===== */
.btn {
  padding: 13px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--accent  { background: var(--accent);  border-color: var(--accent);  color: #04220f; }
.btn--danger  { background: transparent;    border-color: var(--bad);     color: var(--bad); }
.btn--ghost   { background: transparent; }

/* ===== Hojas (revisión e historial) ===== */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 12px;
  padding: calc(var(--safe-top) + 14px) 14px calc(var(--safe-bottom) + 14px);
  background: var(--bg);
}
.sheet[hidden] { display: none; }

#review-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  min-height: 0;
  border-radius: 12px;
  background: #000;
}

.sheet__actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 10px;
}

.sheet--full { grid-template-rows: auto auto 1fr auto; }
.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sheet__head h2 { margin: 0; font-size: 18px; }
.sheet__hint { margin: 0; color: var(--muted); font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
  overflow-y: auto;
  align-content: start;
  min-height: 0;
}
.grid__empty { color: var(--muted); font-size: 14px; grid-column: 1 / -1; }

.thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb__bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 1px;
  background: rgba(0, 0, 0, .55);
}
.thumb__bar button {
  flex: 1;
  padding: 7px 0;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}
.thumb__date {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 4px 6px;
  background: rgba(0, 0, 0, .55);
  font-size: 10px;
  color: #fff;
}

/* ===== Aviso flotante ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 100px);
  transform: translateX(-50%);
  z-index: 40;
  max-width: 90vw;
  padding: 11px 16px;
  border-radius: 999px;
  background: rgba(20, 27, 35, .97);
  border: 1px solid var(--line);
  font-size: 14px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.toast[hidden] { display: none; }
