/* ===== Catastro de Baches — Estilos ===== */
:root {
  --primary: #0b6eb0;
  --primary-dark: #083f66;
  --accent: #109ee2;
  --success: #1a7f37;
  --danger: #c62828;
  --warning: #e67e22;
  --bg: #f1f6fb;
  --card: #fff;
  --text: #12324d;
  --muted: #5b7289;
  --border: #dbe7f1;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

/* ===== Pantallas ===== */
.screen { display: none; position: fixed; inset: 0; z-index: 1; }
.screen.active { display: flex; flex-direction: column; }

/* ===== Mapa ===== */
#mapa { position: absolute; inset: 0; z-index: 0; }
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--primary); color: #fff;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 1.6rem; }
.brand small { display: block; opacity: 0.85; font-size: 0.75rem; }
.icon-btn {
  background: rgba(255,255,255,0.15); border: none; color: #fff;
  font-size: 1.3rem; width: 40px; height: 40px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}

.leyenda {
  position: absolute; bottom: 100px; left: 12px; z-index: 1000;
  background: rgba(255,255,255,0.95); border-radius: 10px; padding: 8px 12px;
  display: flex; gap: 12px; font-size: 0.75rem; box-shadow: var(--shadow);
}
.leyenda span { display: flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-leve { background: #27ae60; }
.dot-moderado { background: var(--warning); }
.dot-grave { background: var(--danger); }

.fab {
  position: absolute; bottom: 28px; right: 16px; z-index: 1000;
  background: var(--primary); color: #fff; border: none;
  padding: 16px 22px; border-radius: 50px; font-size: 1rem; font-weight: 700;
  box-shadow: 0 4px 16px rgba(11,110,176,0.45); cursor: pointer;
}

/* ===== Cabecera de pantallas ===== */
.screen-header {
  display: flex; align-items: center; gap: 12px;
  background: var(--primary); color: #fff;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  box-shadow: var(--shadow);
}
.screen-header h1 { font-size: 1.1rem; }

.content { flex: 1; overflow-y: auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }

/* ===== Pasos ===== */
.paso h2 { font-size: 1.05rem; margin-bottom: 6px; color: var(--primary-dark); }
.hint { color: var(--muted); font-size: 0.85rem; margin-bottom: 12px; }
.paso { margin-bottom: 20px; }

/* ===== Botones ===== */
.btn {
  border: none; border-radius: 10px; padding: 13px 18px; font-weight: 600;
  font-size: 0.95rem; cursor: pointer; display: inline-block; text-align: center;
  font-family: inherit; transition: opacity .15s;
}
.btn:active { opacity: 0.8; }
.btn-lg { width: 100%; padding: 15px; font-size: 1rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-secondary { background: #e2e9f0; color: var(--text); }
.btn-link { background: none; color: var(--primary); text-decoration: underline; font-weight: 600; }

/* ===== Campos ===== */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 5px; }
.field input, .field textarea {
  width: 100%; padding: 12px; border: 1.5px solid var(--border); border-radius: 10px;
  font-size: 1rem; font-family: inherit; background: #fff;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }

/* ===== GPS ===== */
.gps-status { margin-top: 10px; padding: 10px; border-radius: 8px; background: #e8f4fd; font-size: 0.85rem; }
.gps-status.ok { background: #e6f7ec; color: var(--success); }
.gps-status.err { background: #fdecea; color: var(--danger); }
.hidden { display: none !important; }
.coords { font-size: 0.8rem; color: var(--muted); margin-top: 6px; font-family: monospace; }

.mini-mapa { height: 180px; border-radius: 10px; margin-top: 10px; border: 1.5px solid var(--border); }

/* ===== Fotos ===== */
.foto-actions { margin-bottom: 12px; }
.preview-fotos { display: flex; flex-wrap: wrap; gap: 8px; }
.preview-fotos .foto-item { position: relative; }
.preview-fotos img { width: 90px; height: 90px; object-fit: cover; border-radius: 10px; border: 1.5px solid var(--border); }
.foto-item .del { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff;
  border: none; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; font-size: 0.8rem; }

/* ===== Chips de problema ===== */
.problemas { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  background: #fff; border: 1.5px solid var(--border); border-radius: 50px;
  padding: 10px 14px; font-size: 0.85rem; cursor: pointer; font-family: inherit;
}
.chip.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== Resumen ===== */
.resumen { background: #fff; border: 1.5px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 16px; font-size: 0.9rem; }
.resumen .row { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.resumen .row:last-child { border: none; }
.resumen .k { color: var(--muted); }
.resumen .v { font-weight: 600; text-align: right; }

/* ===== Navegación de pasos ===== */
.nav-pasos { display: flex; gap: 10px; margin-top: 8px; }
.nav-pasos .btn { flex: 1; }

/* ===== Éxito ===== */
.exito-box { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; gap: 14px; }
.exito-icon { font-size: 4rem; }
.exito-box h1 { color: var(--success); }

/* ===== Auth ===== */
.auth-box { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 30px; max-width: 420px; margin: 0 auto; width: 100%; }
.auth-logo { font-size: 3.5rem; text-align: center; margin-bottom: 6px; }
.auth-box h1 { text-align: center; color: var(--primary-dark); }
.auth-sub { text-align: center; color: var(--muted); font-size: 0.9rem; margin: 6px 0 20px; }
.auth-error { background: #fdecea; color: var(--danger); padding: 10px; border-radius: 8px; margin-bottom: 12px; font-size: 0.85rem; }
.auth-box .btn { margin-bottom: 8px; }

/* ===== Drawer ===== */
.drawer { position: fixed; inset: 0; z-index: 2000; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.drawer-panel {
  position: absolute; top: 0; right: 0; height: 100%; width: 280px;
  background: #fff; box-shadow: -4px 0 20px rgba(0,0,0,0.2);
  padding: calc(20px + env(safe-area-inset-top)) 16px;
  display: flex; flex-direction: column;
}
.drawer-user { font-weight: 700; padding: 12px 8px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.drawer-item { display: block; padding: 13px 8px; color: var(--text); text-decoration: none; font-weight: 500; border-radius: 8px; }
.drawer-item:active { background: var(--bg); }
.drawer-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 8px; }

/* Popup del mapa */
.leaflet-popup-content { font-family: inherit; }
.leaflet-popup-content h3 { margin: 0 0 4px; font-size: 0.95rem; }
.leaflet-popup-content p { margin: 2px 0; font-size: 0.8rem; }
.leaflet-popup-content img { width: 100%; max-height: 110px; object-fit: cover; border-radius: 6px; margin-top: 6px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 0.7rem; color: #fff; font-weight: 700; }
.badge-leve { background: #27ae60; }
.badge-moderado { background: var(--warning); }
.badge-grave { background: var(--danger); }
.badge-pendiente { background: #7f8c8d; }
.badge-reparado { background: #27ae60; }
