/* app.css — Alto contraste para leer bajo sol directo. Sin fuentes externas: no hay internet. */

:root {
  /* Los controles nativos (calendario, desplegables, barras de scroll) se pintan
     según esto. Sin declararlo, el selector de fecha sale claro sobre fondo oscuro. */
  color-scheme: light;

  --bg: #faf8f5;          /* crema, no blanco puro: menos deslumbre bajo el sol */
  --superficie: #ffffff;
  --superficie-2: #f2ede7;
  --texto: #14110e;
  --texto-suave: #5c544c;
  --borde: #d6cfc7;
  --acento: #b93d08;      /* terracota */
  --acento-texto: #ffffff;
  --alerta: #b3261e;
  --alerta-bg: #fdecea;
  --ok: #1b5e20;
  --sombra: 0 1px 3px rgba(0, 0, 0, .12);
  --radio: 12px;
  --toque: 48px;          /* mínimo táctil: pulgar, en movimiento, en un bus */
  --nav-alto: 62px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    color-scheme: dark;
    --bg: #12100e;
    --superficie: #1e1b18;
    --superficie-2: #2a2622;
    --texto: #f5f1ec;
    --texto-suave: #a79e94;
    --borde: #3a3430;
    --acento: #fb923c;
    --acento-texto: #1a1005;
    --alerta: #ff6b6b;
    --alerta-bg: #3a1a18;
    --ok: #7bc47f;
    --sombra: 0 1px 3px rgba(0, 0, 0, .5);
  }
}

:root[data-tema="oscuro"] {
  color-scheme: dark;
  --bg: #12100e;
  --superficie: #1e1b18;
  --superficie-2: #2a2622;
  --texto: #f5f1ec;
  --texto-suave: #a79e94;
  --borde: #3a3430;
  --acento: #fb923c;
  --acento-texto: #1a1005;
  --alerta: #ff6b6b;
  --alerta-bg: #3a1a18;
  --ok: #7bc47f;
  --sombra: 0 1px 3px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;         /* grande: se lee de un vistazo, con el teléfono en movimiento */
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

/* --- Estructura --- */

#app {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px calc(var(--nav-alto) + env(safe-area-inset-bottom, 0px) + 24px);
}

.vista { display: none; }
.vista.activa { display: block; animation: entra .15s ease-out; }

@keyframes entra { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .vista.activa { animation: none; }
  * { transition: none !important; }
}

header.barra {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--borde);
  margin-bottom: 16px;
}

header.barra h1 { font-size: 21px; margin: 0; letter-spacing: -.01em; }
header.barra .sub { color: var(--texto-suave); font-size: 14px; margin-top: 2px; }

h2 { font-size: 18px; margin: 24px 0 10px; }
h2:first-child { margin-top: 0; }

/* --- Navegación inferior: alcance del pulgar --- */

nav.pestanas {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  background: var(--superficie);
  border-top: 1px solid var(--borde);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

nav.pestanas button {
  flex: 1;
  min-height: var(--nav-alto);
  border: 0;
  background: none;
  color: var(--texto-suave);
  font: inherit;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  padding: 6px 2px;
}

nav.pestanas button svg { width: 23px; height: 23px; stroke-width: 1.9; }
nav.pestanas button[aria-selected="true"] { color: var(--acento); font-weight: 600; }

/* --- Tarjetas --- */

.tarjeta {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 15px;
  margin-bottom: 12px;
  box-shadow: var(--sombra);
}

.tarjeta.compacta { padding: 12px; }

/* --- Formularios --- */

label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--texto-suave); }

input, textarea, select {
  width: 100%;
  min-height: var(--toque);
  padding: 11px 13px;
  font: inherit;
  color: var(--texto);
  background: var(--superficie);
  border: 1.5px solid var(--borde);
  border-radius: 10px;
  margin-bottom: 14px;
}

textarea { min-height: 110px; resize: vertical; line-height: 1.5; }

input:focus, textarea:focus, select:focus, button:focus-visible {
  outline: 3px solid var(--acento);
  outline-offset: 1px;
  border-color: var(--acento);
}

/* --- Botones --- */

button {
  font: inherit;
  /* Sin esto los botones usan el negro del sistema en vez del color del tema,
     y en modo oscuro el texto desaparece sobre el fondo. */
  color: inherit;
  cursor: pointer;
  border-radius: 10px;
  min-height: var(--toque);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  background: var(--acento);
  color: var(--acento-texto);
  border: 0;
  font-weight: 650;
}

.btn:active { transform: scale(.98); }
.btn.ancho { width: 100%; }

.btn.secundario {
  background: var(--superficie);
  color: var(--texto);
  border: 1.5px solid var(--borde);
}

.btn.peligro { background: var(--alerta); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Acciones rápidas: lo que se toca a diario, sin buscar */
.acciones-rapidas {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 20px;
}

.acciones-rapidas .btn { padding: 15px 6px; flex-direction: column; gap: 6px; font-size: 13px; }
.acciones-rapidas .btn svg { width: 22px; height: 22px; }

/* --- Avisos --- */

.aviso {
  border-radius: var(--radio);
  padding: 13px 15px;
  margin-bottom: 14px;
  font-size: 15px;
  border: 1.5px solid;
}

.aviso.alerta { background: var(--alerta-bg); border-color: var(--alerta); color: var(--alerta); font-weight: 600; }
.aviso.info { background: var(--superficie-2); border-color: var(--borde); color: var(--texto-suave); }

/* --- Etiquetas / chips --- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

.chip {
  padding: 9px 15px;
  min-height: 42px;
  border-radius: 999px;
  border: 1.5px solid var(--borde);
  background: var(--superficie);
  color: var(--texto);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
}

.chip[aria-pressed="true"] { background: var(--acento); color: var(--acento-texto); border-color: var(--acento); font-weight: 600; }

/* --- Estado vacío --- */

.vacio { text-align: center; color: var(--texto-suave); padding: 44px 20px; font-size: 15px; }
.vacio svg { width: 44px; height: 44px; opacity: .4; margin-bottom: 12px; }

/* --- Utilidades --- */

.fila { display: flex; gap: 10px; align-items: center; }
.fila.entre { justify-content: space-between; }
.crece { flex: 1; }
.suave { color: var(--texto-suave); font-size: 14px; }
.mono { font-variant-numeric: tabular-nums; }
.oculto { display: none !important; }
.cifra { font-size: 30px; font-weight: 700; letter-spacing: -.02em; }

/* Mensaje de guardado: confirma que el dato quedó en disco antes de limpiar el formulario */
#brindis {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-alto) + env(safe-area-inset-bottom, 0px) + 16px);
  transform: translateX(-50%) translateY(14px);
  background: var(--texto);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 40;
  max-width: 90vw;
  text-align: center;
}

#brindis.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
#brindis.error { background: var(--alerta); color: #fff; }
