/* ============================================================
   VLA REAL — Estilos compartidos
   Observatorio Ciudadano de Villa La Angostura
============================================================ */

:root {
  --forest:        #1f3d2e;
  --forest-dark:   #0f2418;
  --forest-light:  #3d6b56;
  --forest-soft:   #5a7d6b;
  --paper:         #f5efe2;
  --paper-warm:    #ebe4d3;
  --cream:         #faf6ee;
  --copper:        #b86c3c;
  --copper-light:  #d68e5f;
  --copper-dark:   #8a4f2a;
  --ink:           #1a1a1a;
  --ink-soft:      #4a4a4a;
  --ink-muted:     #8a8a8a;
  --ink-faint:     #b0b0b0;
  --line:          #d8d0bf;
  --line-soft:     #e8dfcc;
  --danger:        #a83a3a;
  --warn:          #c89c2e;
  --ok:            #5a8a4a;

  /* Status colors for catastro completion */
  --status-empty:  #b8b0a0;
  --status-part:   #d4a83a;
  --status-done:   #5a8a4a;

  /* Categorías Reportes */
  --cat-vialidad:    #c4633e;
  --cat-cartel:      #d4a83a;
  --cat-cruce:       #a83a3a;
  --cat-agua:        #3a6b8c;
  --cat-riego:       #4a9bb8;
  --cat-luz:         #c89c2e;
  --cat-arbol:       #5a8a4a;
  --cat-residuos:    #8a6a4a;
  --cat-edificio:    #6a6a7a;
  --cat-inseguridad: #5a3a5a;
  --cat-otros:       #3d6b56;

  /* Categorías Sugerencias */
  --sug-educacion: #4a6b8c;
  --sug-seguridad: #a83a3a;
  --sug-economia:  #c89c2e;
  --sug-salud:     #c4633e;
  --sug-sociedad:  #5a8a4a;
  --sug-politica:  #5a3a5a;

  --shadow-sm: 0 1px 2px rgba(31,61,46,.08);
  --shadow:    0 4px 12px rgba(31,61,46,.10);
  --shadow-lg: 0 12px 32px rgba(31,61,46,.18);
  --shadow-xl: 0 20px 50px rgba(15,36,24,.25);

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Paper grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: .35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.08 0 0 0 0 0.05 0 0 0 .35 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

h1, h2, h3, h4, h5 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.15;
  margin: 0;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a { color: var(--copper-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   APP CONTAINER
============================================================ */
#app {
  position: relative;
  min-height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: var(--shadow-xl);
}

/* ============================================================
   HEADER
============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 1400;
  background: var(--forest);
  color: var(--cream);
  padding: 12px 18px;
  border-bottom: 1px solid var(--forest-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.app-header .back-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(245,239,226,.1);
  display: grid; place-items: center;
  font-size: 18px;
  color: var(--cream);
  flex-shrink: 0;
}
.app-header .back-btn:hover { background: rgba(245,239,226,.18); }

.app-header .header-title {
  flex: 1;
  min-width: 0;
}
.app-header .header-title .crumb {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: rgba(245,239,226,.6);
  font-weight: 500;
  margin-bottom: 1px;
}
.app-header .header-title h1 {
  font-size: 18px;
  letter-spacing: -.01em;
}

.app-header .header-meta {
  font-size: 11px;
  color: rgba(245,239,226,.7);
  text-align: right;
  line-height: 1.2;
  flex-shrink: 0;
}
.app-header .header-meta strong {
  display: block;
  font-family: 'Fraunces', serif;
  font-size: 17px;
  color: var(--cream);
  font-style: italic;
}

/* ============================================================
   MAIN
============================================================ */
main {
  position: relative;
  min-height: calc(100dvh - 60px);
  padding-bottom: 40px;
}

/* ============================================================
   BUTTONS
============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: all .15s;
  background: var(--cream);
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn:hover { background: white; }
.btn-primary {
  background: var(--copper);
  color: var(--cream);
  border-color: var(--copper);
}
.btn-primary:hover:not(:disabled) { background: var(--copper-dark); }
.btn-primary:disabled { background: var(--line); color: var(--ink-muted); cursor: not-allowed; border-color: var(--line); }
.btn-secondary {
  background: var(--forest);
  color: var(--cream);
  border-color: var(--forest);
}
.btn-secondary:hover { background: var(--forest-dark); }
.btn-block { width: 100%; padding: 14px; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--cream); }

/* ============================================================
   FORMS
============================================================ */
textarea, .text-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--cream);
  border: 1.5px solid var(--line-soft);
  border-radius: var(--radius);
  font-size: 14px;
  resize: vertical;
  outline: none;
  transition: border-color .15s;
  color: var(--ink);
}
textarea:focus, .text-input:focus { border-color: var(--forest); }
textarea { min-height: 88px; line-height: 1.5; }

.field-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 6px;
}
.field-hint {
  font-size: 12px;
  color: var(--ink-muted);
  margin-bottom: 8px;
}
.field-step-num {
  display: inline-block;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 13px;
  color: var(--copper);
  margin-right: 6px;
  font-weight: 500;
}
.field-block { margin-bottom: 22px; }

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (max-width: 380px) {
  .option-grid { grid-template-columns: 1fr; }
}

.option-card {
  background: var(--cream);
  border: 1.5px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  transition: all .15s;
}
.option-card:hover { border-color: var(--line); }
.option-card.selected {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(31,61,46,.08);
}
.option-card .card-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-size: 16px;
  background: var(--paper-warm);
  flex-shrink: 0;
}
.option-card .card-text { display: flex; flex-direction: column; min-width: 0; }
.option-card .card-text strong { font-size: 13px; font-weight: 600; }
.option-card .card-text span { font-size: 11px; color: var(--ink-muted); line-height: 1.2; }

/* Radio-style row */
.radio-group { display: flex; flex-direction: column; gap: 6px; }
.radio-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--cream);
  border: 1.5px solid var(--line-soft);
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
}
.radio-row:hover { border-color: var(--line); }
.radio-row.selected { border-color: var(--forest); background: var(--cream); box-shadow: 0 0 0 3px rgba(31,61,46,.08); }
.radio-row .indicator {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line);
  flex-shrink: 0;
  transition: all .15s;
  position: relative;
}
.radio-row.selected .indicator { border-color: var(--forest); }
.radio-row.selected .indicator::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--forest);
}

/* ============================================================
   CARDS / TILES
============================================================ */
.tile {
  background: var(--cream);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 16px;
}

/* ============================================================
   EMPTY STATE
============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--ink-muted);
}
.empty-state .ico { font-size: 42px; margin-bottom: 10px; opacity: .4; }
.empty-state h3 { font-size: 20px; color: var(--ink-soft); margin-bottom: 6px; }
.empty-state p { font-size: 14px; }

/* ============================================================
   MODAL
============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  z-index: 9000;
  background: rgba(15,36,24,.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }

.modal { 
  width: 100%;
  max-width: 540px;
  max-height: 92dvh;
  background: var(--paper);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow-y: auto;
  position: relative;
  z-index: 9001;
  animation: slideUp .25s cubic-bezier(.2,.8,.3,1);
}

/* Leaflet dentro de modales: bajar z-index para que no se escape del modal */
.modal .leaflet-pane,
.modal .leaflet-top,
.modal .leaflet-bottom {
  z-index: auto !important;
}
.modal .leaflet-control { z-index: 800 !important; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-handle {
  width: 36px; height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin: 10px auto 8px;
}
.modal-header {
  padding: 4px 22px 16px;
  border-bottom: 1px solid var(--line-soft);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h2 { font-size: 22px; }
.modal-header .close-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--paper-warm);
  display: grid; place-items: center;
  font-size: 18px;
  color: var(--ink-soft);
}
.modal-body { padding: 20px 22px 30px; }

/* ============================================================
   TOAST
============================================================ */
.toast {
  position: fixed;
  top: 80px; left: 50%;
  transform: translateX(-50%) translateY(-150%);
  z-index: 9500;
  background: var(--forest);
  color: var(--cream);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transition: transform .3s cubic-bezier(.2,.8,.3,1);
  white-space: nowrap;
  max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* ============================================================
   FAB
============================================================ */
.fab {
  position: fixed;
  bottom: 24px;
  right: max(18px, calc(50% - 252px));
  z-index: 1500;
  background: var(--copper);
  color: var(--cream);
  width: 60px; height: 60px;
  border-radius: 50%;
  box-shadow: var(--shadow-lg);
  display: grid; place-items: center;
  font-size: 28px;
  font-weight: 300;
  transition: transform .15s, box-shadow .15s;
}
.fab:hover { transform: scale(1.05); }
.fab:active { transform: scale(.95); }
@media (max-width: 540px) {
  .fab { right: 18px; }
}

/* ============================================================
   FILTER CHIPS (used in maps and lists)
============================================================ */
.filter-bar {
  background: var(--paper);
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 12px;
  overflow-x: auto;
  white-space: nowrap;
  position: relative;
  z-index: 2;
}
.filter-bar::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  margin-right: 6px;
  transition: all .15s;
}
.chip:hover { background: var(--paper-warm); }
.chip.active {
  background: var(--forest);
  color: var(--cream);
  border-color: var(--forest);
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cat-otros); }

/* ============================================================
   MAP
============================================================ */
#map, .map-container {
  height: calc(100dvh - 60px - 53px);
  min-height: 380px;
  width: 100%;
  background: #d8d0bf;
}

.map-counter {
  position: absolute;
  bottom: 18px; left: 18px;
  z-index: 1400;
  background: rgba(31,61,46,.92);
  backdrop-filter: blur(8px);
  color: var(--cream);
  padding: 8px 14px;
  border-radius: 24px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow);
  pointer-events: none;
}
.map-counter strong { font-family: 'Fraunces', serif; font-size: 15px; margin-right: 4px; }

/* Custom Leaflet pins */
.custom-pin {
  width: 28px; height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid var(--cream);
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
  display: grid; place-items: center;
}
.custom-pin span {
  transform: rotate(45deg);
  font-size: 14px;
}

/* Catastro pins (smaller, just colored dots) */
.catastro-pin {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0,0,0,.3);
}

/* Leaflet overrides */
.leaflet-container { font-family: 'DM Sans', sans-serif; background: #d8d0bf; }
.leaflet-control-attribution {
  font-size: 9px !important;
  background: rgba(245,239,226,.8) !important;
}
.leaflet-popup-content-wrapper {
  background: var(--cream);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.4; }
.leaflet-popup-content h4 { font-size: 14px; margin-bottom: 4px; color: var(--forest); }
.leaflet-popup-content .popup-tag {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
}
.leaflet-popup-content .popup-action {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--copper);
  cursor: pointer;
}
.leaflet-popup-tip { background: var(--cream); }

/* Marker cluster */
.marker-cluster-custom {
  background: rgba(31,61,46,.85);
  border: 2px solid var(--cream);
  color: var(--cream);
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 13px;
  box-shadow: var(--shadow);
}

/* ============================================================
   PHOTO ZONE
============================================================ */
.photo-zone {
  background: var(--cream);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 13px;
  position: relative;
  cursor: pointer;
}
.photo-zone:hover { background: var(--paper-warm); }
.photo-zone .icn { font-size: 24px; margin-bottom: 4px; opacity: .6; }
.photo-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-preview {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 6px;
}
.photo-preview img { width: 100%; display: block; max-height: 240px; object-fit: cover; }
.photo-preview .remove {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,.6);
  color: white;
  width: 28px; height: 28px;
  border-radius: 50%;
  font-size: 14px;
}

/* ============================================================
   STATUS DOT (catastro completion)
============================================================ */
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}
.status-dot.empty { background: var(--status-empty); }
.status-dot.part  { background: var(--status-part); }
.status-dot.done  { background: var(--status-done); }

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--paper-warm);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  background: var(--copper);
  transition: width .4s ease;
}

/* ============================================================
   UTILITIES
============================================================ */
.muted { color: var(--ink-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11.5px; }
.bold { font-weight: 600; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-1 { gap: 6px; }
.gap-2 { gap: 10px; }
.gap-3 { gap: 14px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 10px; }
.mb-3 { margin-bottom: 14px; }
.mb-4 { margin-bottom: 20px; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 14px; }
.mt-4 { margin-top: 20px; }
.text-center { text-align: center; }
.uppercase { text-transform: uppercase; letter-spacing: .1em; font-weight: 600; font-size: 11px; }
