/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f4f5f7;
  color: #1a1a1a;
  font-size: 17px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: #1c4b8b;
  color: #fff;
}
.topbar__title { font-weight: 600; font-size: 1.05rem; }
.topbar__logout { margin: 0; }

/* ---------- Main / layout ---------- */
.main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.85rem 1.2rem;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  line-height: 1.2;
}
.btn--block { display: block; width: 100%; }
.btn--primary { background: #1c4b8b; color: #fff; }
.btn--primary:hover { background: #15396a; }
.btn--giant {
  font-size: 1.35rem;
  padding: 1.4rem 1.2rem;
  border-radius: 14px;
}
.btn--ghost { background: rgba(255,255,255,0.15); color: #fff; }
.btn--ghost:hover { background: rgba(255,255,255,0.25); }
.btn--danger { background: #b3261e; color: #fff; }
.btn--secondary { background: #e0e3e7; color: #1a1a1a; }
/* Botón llamativo para "Cambiar por mi ubicación actual" (modo modificar) */
.btn--accent {
  background: #e8590c;
  color: #fff;
  box-shadow: 0 4px 14px rgba(232, 89, 12, 0.35);
}
.btn--accent:hover { background: #d24e08; }

/* ---------- Form ---------- */
.form { display: flex; flex-direction: column; gap: 0.9rem; }
.form__field { display: flex; flex-direction: column; gap: 0.35rem; }
.form__label { font-weight: 600; font-size: 0.95rem; }
.form input[type="text"], .form input[type="password"], .form input[type="email"],
.form input[type="file"], .form textarea, .form select,
input.input, textarea.input {
  font-size: 1.05rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid #c4c7cc;
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
}
.form input:focus, input.input:focus { outline: 2px solid #1c4b8b; outline-offset: 1px; }

/* ---------- Flash messages ---------- */
.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-weight: 500;
}
.flash--error { background: #fde7e5; color: #8b1c14; }
.flash--success { background: #dff5e6; color: #0b6e3b; }
.flash--info { background: #e3effb; color: #14467a; }
.flash--warn { background: #fff3cd; color: #6b5300; }

/* ---------- Login card ---------- */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  padding: 2rem 1.5rem;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  margin: 1rem;
}
.login-card__title { margin: 0 0 0.25rem; font-size: 1.25rem; line-height: 1.25; }
.login-card__subtitle { margin: 0 0 0.75rem; color: #555; font-weight: 500; }
.login-card__help { margin: 0 0 1.25rem; color: #6a6f78; font-size: 0.95rem; }

/* ---------- Capture screen ---------- */
.capture { display: flex; flex-direction: column; gap: 1rem; }
.capture-h1 { margin: 0; font-size: 1.35rem; font-weight: 700; line-height: 1.25; }

.capture-cta { margin: 0; }
.capture-view { display: flex; flex-direction: column; gap: 0.85rem; margin: 0; }

/* Indicador de pasos */
.step-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #6a6f78;
  font-weight: 500;
}
.step-indicator__item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  opacity: 0.55;
}
.step-indicator__item--active { opacity: 1; color: #1c4b8b; }
.step-indicator__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #e0e6ef;
  color: #6a6f78;
  font-size: 0.78rem;
  font-weight: 700;
}
.step-indicator__item--active .step-indicator__num { background: #1c4b8b; color: #fff; }
.step-indicator__sep { color: #c0c4cc; }

.status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: #e3effb;
  color: #14467a;
  border-radius: 12px;
  margin: 0;
  font-weight: 500;
  border: 1px solid #d3e2f3;
}
.status--error { background: #fde7e5; color: #8b1c14; border-color: #f6c9c4; }
.status--success { background: #e8f0fb; color: #1c4b8b; border-color: #cad9ee; }
.spinner {
  width: 20px; height: 20px;
  border: 3px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Mapa de captura: integrado, con sombra y bordes suaves */
#map, .capture-map {
  height: 340px;
  width: 100%;
  border-radius: 14px;
  margin: 0;
  background: #eef0f3;
  box-shadow: 0 4px 14px rgba(15, 30, 60, 0.10), 0 1px 2px rgba(15, 30, 60, 0.06);
  overflow: hidden;
}
#map.tappable, .capture-map.tappable {
  outline: 3px dashed #1c4b8b;
  outline-offset: -3px;
}

/* Resumen (modo ya cargado, read-only) */
.capture-summary {
  background: #fff;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border: 1px solid #ececec;
}
.capture-summary__label {
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.capture-summary__value {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
}

.capture-actions { display: flex; flex-direction: column; gap: 0.5rem; margin: 0; }
.capture-actions__hint { margin: 0; }

/* Botón locate de Leaflet */
.locate-control a {
  display: block;
  width: 30px;
  height: 30px;
  line-height: 30px;
  text-align: center;
  font-size: 20px;
  color: #1c4b8b;
  text-decoration: none;
  font-weight: 700;
}
.locate-control a:hover { background: #f0f3f8; }
.locate-control--loading {
  animation: locate-pulse 1s ease-in-out infinite;
}
@keyframes locate-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.hidden { display: none !important; }

.done-card {
  text-align: center;
  padding: 2rem 1rem;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.done-card__msg {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0b6e3b;
  line-height: 1.35;
  margin: 0.5rem 0 0;
}
.done-card__check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px; height: 72px;
  border-radius: 50%;
  background: #1c4b8b;
  color: #fff;
  font-size: 2.4rem;
  margin-bottom: 1rem;
}

/* Comprobante de carga en la pantalla de éxito */
.done-receipt {
  margin: 1.5rem auto 0;
  max-width: 420px;
  text-align: left;
  border: 1px solid #e2e2e2;
  border-radius: 10px;
  padding: 1rem 1.1rem;
  background: #fafafa;
}
.done-receipt__title {
  margin: 0 0 0.75rem;
  font-weight: 700;
  color: #1c4b8b;
  text-align: center;
}
.done-receipt__list { margin: 0; }
.done-receipt__row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid #ececec;
}
.done-receipt__row:last-child { border-bottom: 0; }
.done-receipt__row dt {
  color: #666;
  font-size: 0.9rem;
  flex: 0 0 auto;
}
.done-receipt__row dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}
.done-receipt__tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.05rem 0.4rem;
  border-radius: 6px;
  margin-left: 0.3rem;
  vertical-align: middle;
}
.done-receipt__tag--ok  { background: #d6f0e0; color: #0b6e3b; }
.done-receipt__tag--bad { background: #f6dcd9; color: #b3261e; }
.done-receipt__hint { margin: 0.75rem 0 0; text-align: center; }

/* Banner del comedor en curso (paso de confirmación) */
.capture-comedor-banner {
  background: #eef3fb;
  border: 1px solid #cdddf3;
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.9rem;
  font-size: 0.95rem;
  color: #1c4b8b;
}
.capture-comedor-banner strong { font-weight: 700; }

/* ---------- Admin ---------- */
.admin-nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.admin-nav a {
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  background: #e0e3e7;
  color: #1a1a1a;
  text-decoration: none;
  font-weight: 500;
}
.admin-nav a.active { background: #1c4b8b; color: #fff; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}
.card {
  background: #fff;
  padding: 1.1rem;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: block;
  text-decoration: none;
  color: inherit;
}
.card--link:hover { box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.card__label { font-size: 0.85rem; color: #555; text-transform: uppercase; letter-spacing: 0.04em; }
.card__value { font-size: 2rem; font-weight: 700; margin-top: 0.25rem; }
.card--accent .card__value { color: #1c4b8b; }
.card--warn .card__value { color: #b3261e; }

.section {
  background: #fff;
  border-radius: 12px;
  padding: 1.2rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.section h2 { margin-top: 0; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid #ececec; vertical-align: top; }
.table th { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: #555; }
.table .right { text-align: right; }
.table tr:hover { background: #fafafa; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  border-radius: 999px;
  font-weight: 600;
}
.badge--ok { background: #dff5e6; color: #0b6e3b; }
.badge--bad { background: #fde7e5; color: #8b1c14; }
.badge--warn { background: #fff3cd; color: #6b5300; }
.badge--neutral { background: #e0e3e7; color: #333; }

.export-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; }

#admin-map {
  height: 520px;
  width: 100%;
  border-radius: 14px;
  background: #eef0f3;
  box-shadow: 0 4px 14px rgba(15, 30, 60, 0.10), 0 1px 2px rgba(15, 30, 60, 0.06);
  overflow: hidden;
}

/* Header del listado por categoría */
.listado-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.listado-header__title { margin: 0; }
.listado-header .export-buttons { margin-top: 0.25rem; }

/* Tarjeta del dashboard como link clickeable */
a.card { transition: transform 0.08s ease, box-shadow 0.15s ease; }
a.card:hover { box-shadow: 0 6px 14px rgba(15,30,60,0.12); transform: translateY(-1px); }
a.card:active { transform: translateY(0); }

.form--inline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
  align-items: end;
}
.form--inline .form__field { margin: 0; }
.form--inline .btn { height: 46px; }

.row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.muted { color: #777; }
.small { font-size: 0.85rem; }

@media (max-width: 480px) {
  #map { height: 320px; }
}
