:root {
  color-scheme: light;
  --bg: #fafaf9;
  --card: #ffffff;
  --ink: #1c1917;
  --muted: #57534e;
  --brand: #4d7c0f;
  --brand-soft: #f0fdf4;
  --accent: #d97706;
  --danger: #dc2626;
  --shadow: 0 4px 12px rgba(28, 25, 23, 0.08);
  --fast: 160ms ease;
  --drawer: 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding-bottom: 92px;
}

button, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(760px, 100%);
  margin: 0 auto;
}

.hero {
  position: sticky;
  top: 0;
  z-index: 10;
  overflow-anchor: none;
  padding: 20px 16px 14px;
  background: linear-gradient(180deg, #f0fdf4 0%, rgba(250, 250, 249, 0.96) 88%);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid #e7e5e4;
  box-shadow: 0 0 0 rgba(15, 23, 42, 0);
  transition: padding var(--fast), box-shadow var(--fast), background var(--fast);
}

.hero.is-compact {
  padding-top: 10px;
  padding-bottom: 8px;
  background: rgba(250, 250, 249, 0.92);
  box-shadow: 0 8px 24px rgba(28, 25, 23, 0.06);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.76rem;
  transition: opacity var(--fast), max-height var(--fast), margin var(--fast), transform var(--fast);
}

.hero.is-compact .eyebrow {
  max-height: 0;
  margin: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-6px);
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  line-height: 1.1;
  transition: font-size var(--fast), margin var(--fast);
}

.hero.is-compact h1 {
  margin-bottom: 6px;
  font-size: clamp(1.18rem, 4.5vw, 1.42rem);
}

.hero-copy {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 1.02rem;
  transition: opacity var(--fast), max-height var(--fast), margin var(--fast), transform var(--fast);
}

.hero.is-compact .hero-copy {
  max-height: 0;
  margin: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-6px);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 0 16px;
  background: var(--card);
  border: 1px solid #d6d3d1;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(28, 25, 23, 0.05);
  transition: min-height var(--fast), border-radius var(--fast), box-shadow var(--fast), border-color var(--fast);
}

.search-box:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.hero.is-compact .search-box {
  min-height: 48px;
  border-radius: 10px;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  font-size: 1.05rem;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.quick-filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}
.quick-filters::-webkit-scrollbar { display: none; }

.category-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 16px 16px 4px;
  scrollbar-width: none;
}

#map-container {
  width: 100%;
  height: 40vh;
  margin-bottom: 0;
  border-bottom: 1px solid #e7e5e4;
  z-index: 1; /* Por debajo de la barra pegajosa */
}

/* Corregir z-index de Leaflet para que no tape el header */
.leaflet-top, .leaflet-bottom { z-index: 5 !important; }
.leaflet-pane { z-index: 1 !important; }
.category-strip::-webkit-scrollbar { display: none; }

.filter-chip,
.category-chip {
  flex: 0 0 auto;
  border: 1px solid #e7e5e4;
  border-radius: 10px;
  min-height: 40px;
  padding: 0 14px;
  background: #fff;
  color: var(--muted);
  font-weight: 700;
  transition: all var(--fast);
}

.filter-chip:active,
.category-chip:active,
.view-toggle-button:active,
.bottom-nav button:active { transform: scale(0.97); }

.filter-chip.is-active,
.category-chip.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.view-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: #f5f5f4;
  border: 1px solid #e7e5e4;
  flex: 0 0 auto;
}

.view-toggle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  transition: background var(--fast), color var(--fast), transform var(--fast);
}

.view-toggle-button span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.view-toggle-button.is-active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.1);
}

.status-card {
  margin: 14px 16px 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: #fefce8;
  border: 1px solid #fef08a;
  color: #854d0e;
  font-weight: 700;
}

.business-grid {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.business-grid.is-mosaic {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.business-grid.is-list {
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 16px;
}

.business-card {
  width: 100%;
  border: 1px solid #e7e5e4;
  text-align: left;
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(28, 25, 23, 0.04);
  transition: transform var(--fast), box-shadow var(--fast), border-radius var(--fast);
}

.business-card:hover { box-shadow: 0 8px 16px rgba(28, 25, 23, 0.08); }
.business-card:active { transform: translateY(1px) scale(0.99); }

.business-grid.is-list .business-card {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 14px;
  align-items: center;
  padding: 12px;
}

.business-grid.is-mosaic .business-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 178px;
  aspect-ratio: 1 / 1;
  padding: 12px;
}

.business-logo-wrap {
  display: inline-flex;
  flex: 0 0 auto;
}

.business-card img {
  object-fit: cover;
  background: var(--brand-soft);
}

.business-grid.is-list .business-card img {
  width: 78px;
  height: 78px;
  border-radius: 8px;
}

.business-grid.is-mosaic .business-card img {
  width: 58px;
  height: 58px;
  border-radius: 8px;
}

.business-card-body {
  display: block;
  min-width: 0;
}

.business-card h2 {
  margin: 0 0 7px;
  font-size: 1.18rem;
  font-weight: 800;
}

.business-grid.is-mosaic .business-card h2 {
  display: -webkit-box;
  margin-bottom: 8px;
  overflow: hidden;
  font-size: clamp(0.95rem, 4vw, 1.1rem);
  line-height: 1.1;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
}

.business-grid.is-mosaic .card-meta {
  gap: 6px;
  font-size: 0.82rem;
}

.open-badge,
.closed-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.82rem;
  font-weight: 700;
}
.open-badge { background: #f0fdf4; color: #166534; border: 1px solid #dcfce7; }
.closed-badge { background: #fef2f2; color: #991b1b; border: 1px solid #fee2e2; }

.business-grid.is-mosaic .open-badge,
.business-grid.is-mosaic .closed-badge {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.74rem;
}

.specialty-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.business-grid.is-mosaic .specialty-row {
  flex-wrap: nowrap;
  overflow: hidden;
}

.specialty-row span {
  padding: 3px 8px;
  border-radius: 6px;
  background: #f5f5f4;
  color: #57534e;
  font-size: 0.78rem;
  font-weight: 600;
}

.business-grid.is-mosaic .specialty-row span {
  flex: 0 0 auto;
  font-size: 0.72rem;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
  font-size: 1.08rem;
}

.bottom-nav {
  position: fixed;
  z-index: 50;
  left: 0;
  bottom: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  padding: 6px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid #e7e5e4;
  box-shadow: 0 -4px 12px rgba(28, 25, 23, 0.04);
}

.bottom-nav button {
  border: 0;
  border-radius: 8px;
  min-height: 52px;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 700;
  transition: all var(--fast);
}

.bottom-nav span {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
}

.bottom-nav button.is-active {
  background: var(--brand-soft);
  color: var(--brand);
}

.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: end center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--drawer);
}

.modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  opacity: 0;
  transition: opacity var(--drawer);
}

.modal.is-open .modal-backdrop { opacity: 1; }

.modal-card {
  position: relative;
  width: min(760px, 100%);
  max-height: 88vh;
  overflow: auto;
  border-radius: 16px 16px 0 0;
  padding: 0 0 32px;
  background: var(--card);
  box-shadow: var(--shadow);
  transform: translateY(42px) scale(0.98);
  transition: transform var(--drawer);
  will-change: transform;
}

.modal.is-open .modal-card { transform: translateY(0) scale(1); }

.modal-card::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  width: 48px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.4);
}

.modal-close {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 10;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
}

.modal-header {
  position: relative;
  min-height: 160px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.modal-cover {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 0;
}

.modal-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  /* Degradado con una base más oscura y un tinte sutil arriba para proteger el botón de cierre */
  background: linear-gradient(
    to top, 
    rgba(28, 25, 23, 0.95) 0%, 
    rgba(28, 25, 23, 0.4) 50%, 
    rgba(28, 25, 23, 0.25) 100%
  );
}

.modal-header-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 14px;
  align-items: center;
  padding: 16px;
  width: 100%;
  color: #fff;
}

.modal-header-content img {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
}

.modal-header-content h2 {
  margin: 0 0 2px;
  font-size: 1.4rem;
  font-weight: 800;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.modal-header-content .card-meta {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.85rem;
}

.channel-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0;
  padding: 0 16px;
  justify-content: center;
}

.channel-row a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e7e5e4;
  color: #44403c;
  text-decoration: none;
  transition: all var(--fast);
  box-shadow: 0 2px 4px rgba(28, 25, 23, 0.04);
}

.channel-row a:hover {
  transform: translateY(-2px);
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}

.channel-row a:active {
  transform: scale(0.95);
}

.channel-row a svg {
  width: 24px;
  height: 24px;
  display: block;
}

.info-block, 
.schedule-block {
  padding: 0 16px;
  margin-top: 14px;
}

.info-block-inner {
  padding: 16px;
  border-radius: 12px;
  background: #fafaf9;
  border: 1px solid #e7e5e4;
}

.info-block h3 {
  margin: 0 0 12px;
  font-size: 1.1rem;
  font-weight: 800;
}

.info-block ul {
  margin: 0;
  padding-left: 20px;
}

.rating-grid {
  display: grid;
  gap: 10px;
}

.rating-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e7e5e4;
}

@media (min-width: 680px) {
  .business-grid.is-mosaic { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .business-grid.is-list { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 430px) {
  .view-toggle {
    justify-self: end;
    margin-top: 0;
  }
  .business-grid.is-mosaic .business-card { min-height: 164px; }
}


/* Mosaico visual: logo primero, información esencial después. */
.mosaic-meta {
  display: none;
}

.category-pill,
.rating-pill,
.distance-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  font-weight: 700;
}

.category-pill {
  padding: 3px 8px;
  background: #f5f5f4;
  color: #57534e;
  font-size: 0.74rem;
}

.rating-pill {
  padding: 3px 8px;
  background: #fefce8;
  color: #854d0e;
  border: 1px solid #fef08a;
  font-size: 0.74rem;
}

.distance-pill {
  color: var(--muted);
}

.business-grid.is-list .rating-pill,
.business-grid.is-list .mosaic-meta {
  display: none;
}

.business-grid.is-mosaic .business-card {
  position: relative;
  align-items: stretch;
  justify-content: flex-end;
  min-height: 190px;
  padding: 0;
  overflow: hidden;
  background: #1c1917;
}

.business-grid.is-mosaic .business-logo-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  min-height: 0;
}

.business-grid.is-mosaic .business-card img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  box-shadow: none;
}

.business-grid.is-mosaic .business-card::after {
  position: absolute;
  inset: 0;
  z-index: 0;
  content: "";
  background:
    linear-gradient(180deg, rgba(28, 25, 23, 0.1) 0%, rgba(28, 25, 23, 0) 34%),
    linear-gradient(180deg, rgba(28, 25, 23, 0) 38%, rgba(28, 25, 23, 0.76) 78%, rgba(28, 25, 23, 0.92) 100%);
}

.business-grid.is-mosaic .business-card-body {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: end;
  gap: 8px;
  width: 100%;
  min-height: 100%;
  padding: 72px 12px 12px;
}

.business-grid.is-mosaic .rating-pill {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 10px;
  background: rgba(254, 252, 232, 0.94);
  box-shadow: 0 4px 12px rgba(28, 25, 23, 0.15);
}

.business-grid.is-mosaic .business-card h2 {
  min-height: 2.16em;
  margin: 0;
  color: #fff;
  text-shadow: 0 2px 10px rgba(28, 25, 23, 0.6);
}

.business-grid.is-mosaic .card-meta,
.business-grid.is-mosaic .specialty-row {
  display: none;
}

.business-grid.is-mosaic .mosaic-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.business-grid.is-mosaic .category-pill {
  background: rgba(250, 250, 249, 0.92);
  color: #44403c;
}

.business-grid.is-mosaic .open-badge-compact {
  max-width: 100%;
  padding: 3px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.72rem;
  box-shadow: 0 4px 10px rgba(28, 25, 23, 0.15);
}

.schedule-block {
  margin: 18px 0 0;
}

.schedule-toggle {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--brand);
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  transition: transform var(--fast), background var(--fast);
}

.schedule-toggle:active {
  transform: scale(0.98);
}

.schedule-panel {
  margin-top: 10px;
  padding: 12px;
  border-radius: 10px;
  background: #fafaf9;
  border: 1px solid #e7e5e4;
}

.schedule-list {
  display: grid;
  gap: 8px;
}

.schedule-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e7e5e4;
  color: var(--ink);
}

.schedule-row span {
  color: var(--muted);
  font-weight: 700;
  text-align: right;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
