/*
 * TodoCiudad Design System
 * Paleta: ink, sky, earth, node, urgent, safe, muted
 * Display: Space Grotesk | Body: IBM Plex Sans
 */

:root {
  --ink: #0b1220;
  --sky: #1a2744;
  --earth: #2a3d2f;
  --node: #f2c14e;
  --urgent: #e4572e;
  --safe: #3dd6c3;
  --muted: #8b9bb4;
  --panel: rgba(12, 18, 32, 0.92);
  --line: #3a4a66;
  --surface: #141d2e;
  --surface-light: #1e2a42;
  --radius: 8px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--ink);
  color: #e8edf5;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--node);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover {
  color: #f9d97a;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
}

/* ── Layout ── */

.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.map-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* ── Overlay UI ── */

.overlay-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 1rem 1.5rem;
  background: linear-gradient(180deg, rgba(11,18,32,0.95) 0%, rgba(11,18,32,0.7) 70%, transparent 100%);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.brand-accent {
  color: var(--node);
}
.brand-tagline {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
  display: none;
}
@media (min-width: 640px) {
  .brand-tagline { display: inline; }
}

/* ── Search ── */

.search-bar {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  max-width: 500px;
}
.search-bar input {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.9rem;
  backdrop-filter: blur(8px);
  transition: border-color var(--transition), background var(--transition);
}
.search-bar input::placeholder {
  color: var(--muted);
}
.search-bar input:focus {
  outline: none;
  border-color: var(--node);
  background: rgba(255,255,255,0.1);
}
.search-bar button {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  background: var(--node);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.search-bar button:hover {
  background: #f9d97a;
  transform: translateY(-1px);
}

/* ── Nav links ── */

.nav-links {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}
.nav-links a {
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--muted);
  transition: color var(--transition), background var(--transition);
}
.nav-links a:hover {
  color: #fff;
  background: rgba(255,255,255,0.06);
}
.nav-links a.urgent-link {
  color: var(--urgent);
  border: 1px solid var(--urgent);
}
.nav-links a.urgent-link:hover {
  background: rgba(228, 87, 46, 0.15);
}

/* ── Hero ── */

.hero-overlay {
  position: fixed;
  bottom: 3rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  text-align: center;
  pointer-events: none;
}
.hero-overlay h1 {
  font-size: 2.5rem;
  font-weight: 700;
  text-shadow: 0 2px 20px rgba(0,0,0,0.8);
  margin-bottom: 0.3rem;
  pointer-events: auto;
}
.hero-overlay p {
  color: var(--muted);
  font-size: 1rem;
  text-shadow: 0 1px 10px rgba(0,0,0,0.8);
  pointer-events: auto;
}
@media (min-width: 768px) {
  .hero-overlay h1 { font-size: 3.5rem; }
}

.cta-urgent {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.7rem 1.8rem;
  border: none;
  border-radius: var(--radius);
  background: var(--urgent);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  pointer-events: auto;
}
.cta-urgent:hover {
  background: #f06a3e;
  transform: translateY(-2px);
}

/* ── Side Panel ── */

.side-panel {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  max-width: 90vw;
  height: 100vh;
  z-index: 200;
  background: var(--panel);
  backdrop-filter: blur(16px);
  border-left: 1px solid var(--line);
  padding: 1.5rem;
  overflow-y: auto;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.side-panel.open {
  right: 0;
}
.side-panel-close {
  float: right;
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), border-color var(--transition);
}
.side-panel-close:hover {
  color: #fff;
  border-color: #fff;
}

/* ── Place Card ── */

.place-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.6rem;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.place-card:hover {
  background: var(--surface-light);
  border-color: var(--node);
  transform: translateX(3px);
}
.place-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}
.place-card-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
}
.place-card-category {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
  white-space: nowrap;
}
.cat-urgencias, .cat-farmacia_guardia { background: rgba(228,87,46,0.2); color: var(--urgent); }
.cat-farmacia_24h, .cat-farmacia { background: rgba(61,214,195,0.15); color: var(--safe); }
.cat-comisaria { background: rgba(242,193,78,0.15); color: var(--node); }
.cat-correos { background: rgba(139,155,180,0.15); color: var(--muted); }
.cat-recarga_ev { background: rgba(61,214,195,0.1); color: var(--safe); }
.cat-negocio { background: rgba(139,155,180,0.08); color: var(--muted); }

.place-card-address {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.3rem;
}
.place-card-phone {
  font-size: 0.8rem;
  color: var(--safe);
  margin-top: 0.2rem;
}
.place-card-phone a {
  color: var(--safe);
}
.place-card-badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-top: 0.3rem;
  font-weight: 500;
}
.badge-open { background: rgba(61,214,195,0.2); color: var(--safe); }
.badge-24h { background: rgba(242,193,78,0.2); color: var(--node); }
.badge-duty { background: rgba(228,87,46,0.2); color: var(--urgent); }

/* ── Place Detail ── */

.place-detail {
  max-width: 700px;
  margin: 0 auto;
  padding: 6rem 1.5rem 3rem;
}
.place-detail h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}
.place-detail-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}
.place-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}
.place-detail-field {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
}
.place-detail-field label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  display: block;
  margin-bottom: 0.2rem;
}
.place-detail-field span {
  font-size: 0.95rem;
  color: #fff;
}

/* ── Urgency Page ── */

.urgency-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 6rem 1.5rem 3rem;
}
.urgency-page h1 {
  font-size: 2rem;
  margin-bottom: 0.3rem;
}
.urgency-subtitle {
  color: var(--muted);
  margin-bottom: 2rem;
}

.urgency-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
@media (min-width: 768px) {
  .urgency-grid {
    grid-template-columns: 1fr 1fr;
  }
}
@media (min-width: 1024px) {
  .urgency-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.urgency-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.urgency-block-header {
  padding: 1rem 1.2rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.urgency-block-header .count {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 400;
}
.urgency-block-body {
  padding: 0.6rem 1.2rem 1rem;
}
.urgency-block-body .place-card {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 0.7rem 0;
  margin-bottom: 0;
}
.urgency-block-body .place-card:last-child {
  border-bottom: none;
}

.urgency-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}
.icon-urgent { background: rgba(228,87,46,0.2); color: var(--urgent); }
.icon-safe { background: rgba(61,214,195,0.15); color: var(--safe); }
.icon-node { background: rgba(242,193,78,0.15); color: var(--node); }
.icon-muted { background: rgba(139,155,180,0.1); color: var(--muted); }

/* ── Stats bar ── */

.stats-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.stat-chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0.4rem 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--font-display);
}
.stat-chip strong {
  color: #fff;
  font-weight: 600;
}

/* ── Filter bar ── */

.filter-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.filter-btn {
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition);
}
.filter-btn:hover, .filter-btn.active {
  border-color: var(--node);
  color: var(--node);
  background: rgba(242,193,78,0.08);
}

/* ── List view ── */

.list-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 6rem 1.5rem 3rem;
}
.list-page h1 {
  font-size: 1.8rem;
  margin-bottom: 0.3rem;
}
.list-count {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ── Layer toggle ── */

.layer-toggle {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.layer-btn {
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(8px);
}
.layer-btn:hover, .layer-btn.active {
  border-color: var(--node);
  color: var(--node);
}

/* ── Bottom sheet (mobile) ── */

.mobile-sheet {
  display: none;
}
@media (max-width: 767px) {
  .mobile-sheet {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 150;
    background: var(--panel);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    padding: 0.8rem 1rem;
    max-height: 40vh;
    overflow-y: auto;
    transition: transform 0.3s ease;
  }
  .mobile-sheet.collapsed {
    transform: translateY(calc(100% - 60px));
  }
  .mobile-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--line);
    border-radius: 2px;
    margin: 0 auto 0.5rem;
    cursor: pointer;
  }
  .side-panel { display: none; }
}

/* ── Loading ── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--muted);
}
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--line);
  border-top-color: var(--node);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.5rem;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Empty state ── */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty-state h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: #fff;
}
.empty-state p {
  margin-bottom: 1.25rem;
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.45;
}
.btn-fetch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.25rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--node);
  color: var(--ink);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), opacity var(--transition);
}
.btn-fetch:hover:not(:disabled) {
  transform: translateY(-1px);
}
.btn-fetch:disabled {
  opacity: 0.7;
  cursor: wait;
}

/* ── Back button ── */

.back-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 50;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  transition: color var(--transition);
}
.back-link:hover {
  color: #fff;
}

/* ── Scrollbar ── */

::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ── Utilities ── */

.text-muted { color: var(--muted); }
.text-safe { color: var(--safe); }
.text-urgent { color: var(--urgent); }
.text-node { color: var(--node); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
