/* AFPorteria - sistema de diseno compartido, mismos tokens que
   C:\Afsis\AFClubApp\Web\css\styles.css / C:\Afsis\AFAutomatizacion\Web\index.html.
   Pantalla de kiosko (porteria): touch-first, texto grande, sin sidebar -
   el menu es 4 tiles, cada pantalla se abre a pantalla completa con un
   boton "Volver" arriba. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --border: #dfe2e7;
  --text: #1c1f24;
  --text-muted: #6b7280;
  --text-faint: #9aa1ab;
  --accent: #242f56;
  --accent-2: #3a4a7d;
  --accent-contrast: #ffffff;
  --accent-soft: #e7eaf3;
  --success: #1f8a4c;
  --success-soft: #e6f5ec;
  --danger: #c23b32;
  --danger-soft: #fbeae8;
  --shadow: 0 1px 2px rgba(20, 23, 28, 0.06), 0 8px 24px -12px rgba(20, 23, 28, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --surface: #1d2025;
    --surface-2: #22262c;
    --border: #2e333a;
    --text: #e8eaed;
    --text-muted: #9aa3ad;
    --text-faint: #6b7280;
    --accent: #5c72b0;
    --accent-2: #7488c2;
    --accent-contrast: #ffffff;
    --accent-soft: rgba(92, 114, 176, 0.22);
    --success: #3ecf6b;
    --success-soft: rgba(62, 207, 107, 0.16);
    --danger: #e5534b;
    --danger-soft: rgba(229, 83, 75, 0.16);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px -14px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1d2025;
  --surface-2: #22262c;
  --border: #2e333a;
  --text: #e8eaed;
  --text-muted: #9aa3ad;
  --text-faint: #6b7280;
  --accent: #5c72b0;
  --accent-2: #7488c2;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(92, 114, 176, 0.22);
  --success: #3ecf6b;
  --success-soft: rgba(62, 207, 107, 0.16);
  --danger: #e5534b;
  --danger-soft: rgba(229, 83, 75, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px -14px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Segoe UI Variable", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; transform: none; }

.btn-icono {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  font-size: 17px;
  flex: none;
}

.btn-primario {
  background: var(--accent); border-color: var(--accent); color: var(--accent-contrast);
  padding: 13px 18px; font-size: 15px; font-weight: 600; border-radius: 10px;
}
.btn-secundario { padding: 11px 16px; font-size: 14px; }
.btn-peligro { background: var(--danger); border-color: var(--danger); color: #fff; }

input[type="text"], input[type="search"], input[type="password"], input[type="date"] {
  width: 100%; font-family: inherit; font-size: 17px; padding: 13px 14px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
label {
  display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); margin-bottom: 6px;
}
.campo { margin-bottom: 16px; }

/* ------------------------------- App shell -------------------------------- */

.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar h1 { font-size: 18px; font-weight: 700; margin: 0; }
.topbar .sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.topbar-acciones { display: flex; gap: 8px; align-items: center; }
.topbar-marca { display: flex; align-items: center; gap: 10px; }
.topbar-logo { width: 32px; height: 32px; border-radius: 8px; object-fit: contain; flex: none; }
main { flex: 1; padding: 18px; max-width: 720px; margin: 0 auto; width: 100%; }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.vacio {
  text-align: center; color: var(--text-faint); font-size: 14px; padding: 32px 12px;
}

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg);
  padding: 11px 20px 11px 14px; border-radius: 10px; font-size: 14px;
  box-shadow: var(--shadow); opacity: 0; transition: opacity .2s ease, transform .2s ease;
  pointer-events: none; max-width: calc(100% - 32px); z-index: 200;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

.loading-overlay {
  position: fixed; inset: 0; background: rgba(10, 12, 15, .35);
  display: flex; align-items: center; justify-content: center; z-index: 300;
}
.loading-spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: girar .7s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 12, 15, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 250;
}
.modal {
  width: 100%; max-width: 420px; background: var(--surface); border-radius: 14px;
  border: 1px solid var(--border); box-shadow: var(--shadow); padding: 22px;
}
.modal h2 { font-size: 17px; margin: 0 0 12px; }
.modal p { font-size: 14px; color: var(--text-muted); margin: 0 0 18px; }
.modal-botones { display: flex; justify-content: flex-end; gap: 10px; }
.dni-scan-modal { max-width: 420px; }
#porteriaDniScanVideo { width: 100%; border-radius: 10px; background: #000; display: block; margin-bottom: 4px; }

/* ------------------------------- Login -------------------------------- */

.pantalla-login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow); padding: 32px 26px; text-align: center;
}
.login-logo { width: 56px; height: 56px; border-radius: 12px; margin: 0 auto 16px; object-fit: contain; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-sub { font-size: 13px; color: var(--text-faint); margin: 0 0 22px; }
.login-card .campo { text-align: left; }
.login-error { min-height: 18px; font-size: 12.5px; color: var(--danger); margin-bottom: 10px; }
.login-card .btn-primario { width: 100%; margin-top: 4px; }
.btn-tema-login {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right));
}

/* ------------------------------- Menu (tiles) -------------------------------- */

.menu-marca { text-align: center; padding: 18px 0 8px; }
.menu-marca .razon { font-size: 15px; font-weight: 700; }
.menu-marca .meta { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
@media (max-width: 480px) { .tiles { grid-template-columns: 1fr; } }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); padding: 28px 16px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700; color: var(--text); min-height: 130px; justify-content: center;
}
.tile .icono { display: flex; color: var(--text-muted); }
.tile:active { background: var(--accent-soft); }

/* ------------------------------- Busqueda (Punto de Control / Captura) -------------------------------- */

.busqueda-fila { display: flex; gap: 10px; }
.busqueda-fila input { flex: 1; font-size: 20px; padding: 16px; text-align: center; }
.busqueda-fila button { flex: none; }

/* Input + boton de camara con el tamaño normal de campo (a diferencia de
   .busqueda-fila, pensada para el buscador grande de Punto de Control). */
.campo-fila { display: flex; gap: 10px; }
.campo-fila input { flex: 1; }
.campo-fila button { flex: none; }

.resultado-card {
  border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border);
  margin-top: 18px;
}
.resultado-cabeza {
  padding: 20px 16px 6px; text-align: center; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
}
.resultado-foto { display: flex; justify-content: center; padding: 12px 16px; }

/* Recuadro de foto reutilizable: reemplaza al <img> solo (que antes
   directamente desaparecia cuando no habia foto) por un contenedor que
   siempre esta presente, con una silueta de persona sobria como estado
   "vacio" en vez de nada - mismo criterio en toda la app (Porteria y
   AFClubApp) de aca en adelante. */
.foto-box {
  border-radius: 14px; overflow: hidden; background: rgba(0,0,0,.08);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.foto-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-box .foto-silueta {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); opacity: .6;
}
.foto-box .foto-silueta svg { width: 58%; height: 58%; }
.foto-box--md { width: 110px; height: 110px; }
.foto-box--sm { width: 76px; height: 76px; }
.foto-box--lg { width: 140px; height: 140px; margin: 0 auto; }
.resultado-foto .foto-box { width: 110px; height: 110px; }
.resultado-card--chico .foto-box { width: 76px; height: 76px; }
.resultado-cuerpo { text-align: center; font-size: 22px; font-weight: 700; padding: 6px 16px 16px; }
.resultado-pie { text-align: center; font-size: 17px; font-weight: 700; padding: 16px; background: rgba(0,0,0,.06); }
.resultado-detalle {
  white-space: pre-wrap; font-size: 13px; padding: 12px 16px; background: rgba(0,0,0,.03);
  border-top: 1px solid rgba(0,0,0,.08);
}

/* ------------------------------- No Socios -------------------------------- */

.fila-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.botones-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }

.af-date-field {
  display: flex; align-items: center; justify-content: space-between; cursor: pointer;
  width: 100%; font-family: inherit; font-size: 17px; padding: 13px 14px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.af-date-field:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.af-date-field .af-date-valor.vacio { color: var(--text-faint); }
.af-date-field .af-date-icon { flex: none; margin-left: 8px; display: flex; color: var(--text-muted); }

/* ------------------------- Calendario en popup ------------------------- */
.af-calendar-overlay {
  position: fixed; inset: 0; background: rgba(10, 12, 15, .45); display: flex;
  align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 260;
}
.af-calendar-box {
  width: 100%; max-width: 340px; background: var(--surface); border-radius: 14px;
  border: 1px solid var(--border); box-shadow: var(--shadow); padding: 20px;
}
.af-calendar-top { text-align: center; margin-bottom: 14px; }
.af-calendar-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); }
.af-calendar-selected { font-size: 19px; font-weight: 700; margin-top: 4px; }
.af-calendar-nav {
  display: grid; grid-template-columns: auto auto 1fr auto auto; align-items: center; gap: 4px; margin-bottom: 10px;
}
.af-calendar-nav button {
  background: none; border: none; color: var(--text-muted); font-size: 16px; padding: 6px 8px; border-radius: 6px;
}
.af-calendar-nav button:hover { background: var(--surface-2); }
.af-calendar-month { text-align: center; font-size: 14px; font-weight: 600; }
.af-calendar-days {
  display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px;
  color: var(--text-faint); margin-bottom: 4px; text-transform: uppercase;
}
.af-calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.af-calendar-day {
  aspect-ratio: 1; border: none; background: none; border-radius: 8px; font-size: 13.5px;
  color: var(--text); cursor: pointer;
}
.af-calendar-day:hover { background: var(--surface-2); }
/* Marco cuadrado propio para "hoy", independiente de si tambien esta
   seleccionado - punto de referencia fijo para no perderse al navegar a
   otro mes y despues querer volver al dia actual. */
.af-calendar-day.today { font-weight: 700; color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.af-calendar-day.selected { background: var(--accent); color: var(--accent-contrast); font-weight: 700; }
.af-calendar-empty { aspect-ratio: 1; }
@media (max-width: 420px) { .botones-grid { grid-template-columns: 1fr; } }
.boton-porteria { padding: 16px 10px; font-size: 14.5px; font-weight: 700; }

/* ------------------------------- Actividad -------------------------------- */

.mov-item {
  display: flex; gap: 12px; align-items: center; padding: 12px 14px;
  border-bottom: 1px solid var(--border); cursor: pointer;
}
.mov-item:last-child { border-bottom: none; }
.mov-item:active { background: var(--surface-2); }
.mov-item .estado-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.mov-item.autorizado .estado-dot { background: var(--success); }
.mov-item.no-autorizado .estado-dot { background: var(--danger); }
.mov-item .info { flex: 1; min-width: 0; }
.mov-item .nombre { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mov-item .meta { font-size: 12px; color: var(--text-faint); }
.mov-item .evento-pill {
  font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 100px; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent);
}
.mov-item .evento-pill.ingreso { background: var(--success-soft); color: var(--success); }
.mov-item .evento-pill.egreso { background: var(--accent-soft); color: var(--accent); }

.detalle-meta { margin: -10px 0 14px; color: var(--text-faint); font-size: 12.5px; }
.resultado-card--chico { margin-top: 0; }
.resultado-card--chico .resultado-cabeza { font-size: 11px; padding: 14px 14px 4px; }
.resultado-card--chico .resultado-foto { padding: 10px 14px; }
.resultado-card--chico .resultado-foto img { width: 76px; height: 76px; }
.resultado-card--chico .resultado-cuerpo { font-size: 17px; padding: 4px 14px 12px; }
.resultado-card--chico .resultado-pie { font-size: 14px; padding: 12px; }

/* ------------------------------- Captura de fotos -------------------------------- */

.archivo-box {
  border: 1px dashed var(--border); border-radius: 12px; padding: 20px; text-align: center;
  font-size: 14px; color: var(--text-muted); cursor: pointer; background: var(--surface-2); margin-top: 16px;
}
.archivo-box.con-archivo { color: var(--success); border-color: var(--success); }
