/* Encuesta OP — sistema visual */
:root {
  --bg-deep: #080b10;
  --bg: #0d1219;
  --bg-elevated: #141b26;
  --card: #161e2c;
  --card-hover: #1a2433;
  --text: #f0f4f8;
  --text-muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.22);
  --accent: #38bdf8;
  --accent-dim: rgba(56, 189, 248, 0.14);
  --accent-hover: #7dd3fc;
  --ok: #34d399;
  --ok-dim: rgba(52, 211, 153, 0.12);
  --err: #f87171;
  --err-dim: rgba(248, 113, 113, 0.12);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 1px 0 var(--border-strong) inset, var(--shadow);
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --header-h: 3.75rem;
  --transition: 0.18s ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -30%, rgba(56, 189, 248, 0.08), transparent),
    radial-gradient(ellipse 80% 50% at 100% 0%, rgba(99, 102, 241, 0.06), transparent);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

/* ——— Cabecera ——— */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: var(--header-h);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: rgba(13, 18, 25, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.brand:hover {
  color: var(--text);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, var(--accent), #6366f1);
  color: #0c1220;
  font-size: 0.75rem;
  font-weight: 800;
}

.brand-text {
  line-height: 1.2;
}

.brand-sub {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.header-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  justify-content: flex-end;
}

.session-slot {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem 0.5rem;
  padding: 0.35rem 1rem 0.35rem 0.75rem;
  border-right: 1px solid var(--border);
  min-height: 2.35rem;
  max-width: min(100%, 22rem);
}

.session-slot__user {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.25;
}

.session-slot__sep {
  color: var(--text-muted);
  font-weight: 500;
  user-select: none;
}

.session-slot__rol {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--accent);
  line-height: 1.25;
}

@media (max-width: 640px) {
  .header-tools {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .session-slot {
    align-items: flex-start;
    border-right: none;
    padding-right: 0;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.65rem;
    width: 100%;
  }
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.nav-link {
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

a.nav-link {
  display: inline-block;
}

/* [hidden] + flex: el display del enlace no debe anular el ocultamiento (p. ej. Administración). */
.nav-links a.nav-link[hidden] {
  display: none !important;
}

.nav-link:hover {
  color: var(--text);
  background: var(--border);
}

.nav-link--active {
  color: var(--accent);
  background: var(--accent-dim);
}

.nav-link--cta {
  background: var(--accent);
  color: #0c1220;
}

.nav-link--cta:hover {
  background: var(--accent-hover);
  color: #0c1220;
}

/* ——— Layout main ——— */
main {
  flex: 1;
  padding: 1.5rem 1.25rem 2.5rem;
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
}

main.main-wide {
  max-width: 44rem;
}

main.mapa-main {
  max-width: 1200px;
}

main.main-hero {
  max-width: 1080px;
}

.page-title {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.page-lead {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 36rem;
}

/* ——— Tarjetas ——— */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.card--flush {
  padding: 0;
  overflow: hidden;
}

.card__body {
  padding: 1.35rem 1.5rem;
}

.card-title {
  margin: 0 0 1rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ——— Hero / inicio ——— */
.hero {
  margin-bottom: 0.5rem;
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.65rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
}

.hero-lead {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.feature-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1.5rem;
}

@media (min-width: 540px) {
  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .feature-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.feature {
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: border-color var(--transition), transform var(--transition);
}

.feature:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.feature-icon {
  font-size: 1.35rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}

.feature h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.feature p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ——— Formularios ——— */
.form-section {
  margin-top: 1.35rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.form-section:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.form-section-title {
  margin: 0 0 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

label {
  display: block;
  margin-top: 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

label:first-child {
  margin-top: 0;
}

.form-grid-2 {
  display: grid;
  gap: 0 1rem;
}

@media (min-width: 560px) {
  .form-grid-2 {
    grid-template-columns: 1fr 1fr;
  }

  .form-grid-2 > label {
    margin-top: 0.85rem;
  }

  .form-grid-2 > label:nth-child(-n + 2) {
    margin-top: 0;
  }
}

input,
select,
textarea,
button {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-deep);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:hover,
select:hover,
textarea:hover {
  border-color: rgba(148, 163, 184, 0.35);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

/* ——— Botones ——— */
button {
  border: none;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.85rem;
  background: linear-gradient(180deg, var(--accent) 0%, #0ea5e9 100%);
  color: #0c1220;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

button:hover {
  filter: brightness(1.06);
}

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-dim);
}

button.secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}

button.secondary:hover {
  background: var(--card-hover);
  border-color: var(--border-strong);
  filter: none;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.btn-row button {
  flex: 1 1 auto;
  min-width: 7.5rem;
  margin-top: 0;
}

/* Ocultar del flujo flex (evita huecos si el UA no aplica [hidden] con prioridad). */
.btn-row button[hidden] {
  display: none !important;
}

.btn-row--start {
  justify-content: flex-start;
}

.form-actions {
  margin-top: 1.35rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.form-actions button {
  margin-top: 0;
}

/* ——— Auth (login / registro) ——— */
.auth-card {
  margin-top: 0.5rem;
}

.auth-footer {
  margin-top: 1.25rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
}

.auth-footer a {
  font-weight: 600;
}

/* ——— Mensajes ——— */
.msg {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  margin-top: 1rem;
  font-size: 0.9rem;
  line-height: 1.45;
  border: 1px solid transparent;
}

.msg.err {
  background: var(--err-dim);
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.25);
}

.msg.ok {
  background: var(--ok-dim);
  color: #a7f3d0;
  border-color: rgba(52, 211, 153, 0.22);
}

.msg.info,
.msg.neutral {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border-color: var(--border);
}

/* ——— Foto seleccionada ——— */
.foto-resumen {
  margin-top: 0.85rem;
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
}

.foto-resumen__columna {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  max-width: 100%;
}

.foto-resumen__titulo-prev {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.3;
}

.foto-resumen__preview-wrap {
  width: 140px;
  height: 140px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-deep);
}

.foto-resumen__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.foto-resumen__estado {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ok);
  line-height: 1.4;
}

.foto-resumen__columna .secondary {
  width: auto;
  min-width: 10rem;
  margin-top: 0;
}

/* ——— Webcam ——— */
.webcam-wrap {
  margin-top: 0.75rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}

#webcam {
  width: 100%;
  max-height: 240px;
  display: block;
  vertical-align: middle;
}

/* ——— Cola / lista ——— */
.queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.queue-list li {
  margin: 0;
  padding: 0;
}

.queue-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.queue-item span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-item__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex-shrink: 0;
}

.queue-item .secondary {
  flex: 0 0 auto;
  width: auto;
  min-width: 4.5rem;
  margin-top: 0;
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
}

.queue-item--editando {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.06);
}

.banner-edicion {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.08);
  font-size: 0.9rem;
  color: var(--text);
}

/* display:flex del bloque no debe anular el atributo hidden del navegador */
.banner-edicion[hidden] {
  display: none !important;
}

.banner-edicion .secondary {
  width: auto;
  min-width: 8rem;
  margin-top: 0;
  flex-shrink: 0;
}

/* ——— Mapa ——— */
.map-shell {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

#map {
  height: min(70vh, 640px);
  width: 100%;
  min-height: 320px;
  background: var(--bg-elevated);
}

.leaflet-popup-content-wrapper {
  background: var(--card) !important;
  color: var(--text) !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow) !important;
}

.leaflet-popup-content {
  margin: 0.65rem 0.85rem !important;
  font-size: 0.9rem;
  line-height: 1.45;
}

.leaflet-popup-tip {
  background: var(--card) !important;
  border: 1px solid var(--border-strong);
}

.map-popup-outer .leaflet-popup-content {
  min-width: 240px;
}

.map-popup {
  max-width: 320px;
}

.map-popup__title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.map-popup__meta {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.map-popup__loading {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--accent);
}

.map-popup__muted {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.map-popup__dl {
  margin: 0 0 0.65rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 0.75rem;
  font-size: 0.86rem;
}

.map-popup__dl dt {
  margin: 0;
  color: var(--text-muted);
  font-weight: 500;
}

.map-popup__dl dd {
  margin: 0;
}

.map-popup__img-wrap {
  margin-top: 0.5rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-deep);
}

.map-popup__img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  vertical-align: middle;
}

.map-popup--err {
  color: var(--err);
  font-size: 0.88rem;
}

.leaflet-container {
  font-family: var(--font) !important;
}

.leaflet-control-zoom a {
  background: var(--card) !important;
  color: var(--text) !important;
  border-color: var(--border-strong) !important;
}

.leaflet-control-zoom a:hover {
  background: var(--bg-elevated) !important;
}

/* ——— Badges ——— */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--accent-dim);
  border: 1px solid rgba(56, 189, 248, 0.25);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.pill--muted {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-muted);
}

.pill a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ——— Pie — */
.site-footer {
  padding: 1.25rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.site-footer strong {
  color: var(--text-muted);
  font-weight: 600;
}

/* ——— Tabla administración usuarios — */
.admin-table-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  padding: 0.55rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.admin-table select {
  min-width: 11rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}

.admin-table .btn-cell {
  white-space: nowrap;
}
