:root {
  --bg: #f7f5f0;
  --sidebar-bg: #ffffff;
  --surface: #ffffff;
  --input-bg: #faf9f6;
  --text: #22262b;
  --text-muted: #6b7280;
  --text-soft: #3a3f45;
  --text-faint: #a3a3a3;
  --border: #eceae4;
  --accent: #1d3557;
  --shadow: 0 8px 24px rgba(20, 20, 30, 0.08);
  --radius: 14px;
  --sidebar-w: 320px;
  --detail-w: 360px;
  --gold: #b8860b;
  --map-bg: #e9e7e1;
  --attribution-bg: rgba(255, 255, 255, 0.75);
  --attribution-text: #333;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161b;
    --sidebar-bg: #1b1e25;
    --surface: #242832;
    --input-bg: #1f232b;
    --text: #edeef0;
    --text-muted: #9aa0ab;
    --text-soft: #c7cad0;
    --text-faint: #767c87;
    --border: #2c303a;
    --accent: #7ea6e0;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    --gold: #e0b84d;
    --map-bg: #171a20;
    --attribution-bg: rgba(20, 22, 27, 0.75);
    --attribution-text: #cfd2d8;
  }
}
:root[data-theme="dark"] {
  --bg: #14161b;
  --sidebar-bg: #1b1e25;
  --surface: #242832;
  --input-bg: #1f232b;
  --text: #edeef0;
  --text-muted: #9aa0ab;
  --text-soft: #c7cad0;
  --text-faint: #767c87;
  --border: #2c303a;
  --accent: #7ea6e0;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  --gold: #e0b84d;
  --map-bg: #171a20;
  --attribution-bg: rgba(20, 22, 27, 0.75);
  --attribution-text: #cfd2d8;
}

* { box-sizing: border-box; }

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--bg);
}

#map {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  background: var(--map-bg);
}

/* ---------- Sidebar ---------- */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  padding: 22px 20px 16px;
  overflow-y: auto;
  transition: transform 0.25s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.brand-icon { font-size: 30px; line-height: 1; }

#themeToggle {
  margin-left: auto;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
}
#themeToggle:hover { background: var(--bg); transform: rotate(15deg); }
.brand h1 {
  font-family: 'Poppins', sans-serif;
  font-size: 19px;
  margin: 0;
  color: var(--accent);
  letter-spacing: -0.01em;
}
.tagline {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.search-box { margin-bottom: 12px; }
.search-box input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.search-box input:focus { border-color: var(--accent); background: var(--surface); }

.filter-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.filter-actions button {
  flex: 1;
  padding: 7px 0;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  font-family: inherit;
}
.filter-actions button:hover { background: var(--bg); color: var(--text); }

.favorites-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.15s;
}
.favorites-toggle .fav-star { color: #d9b64a; font-size: 15px; }
.favorites-toggle:hover { background: var(--bg); }
.favorites-toggle.active {
  background: #fff8e6;
  border-color: #f0d78c;
  color: #8a6d1f;
}
.favorites-toggle .cat-count { margin-left: auto; }

.destacados-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 11px 14px;
  margin-bottom: 14px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: #5a3d00;
  background: linear-gradient(135deg, #ffe8a3, #f0c14b);
  box-shadow: 0 2px 8px rgba(191, 149, 21, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}
.destacados-toggle:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(191, 149, 21, 0.45); }
.destacados-toggle .destacados-star { font-size: 16px; }
.destacados-toggle.active {
  background: linear-gradient(135deg, #ffd15c, #d99a00);
  color: #3d2900;
  box-shadow: 0 0 0 2px #ffd15c, 0 4px 14px rgba(191, 149, 21, 0.55);
}

#normalFilters.dimmed {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(60%);
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.advanced-filters {
  margin-bottom: 10px;
}
.advanced-filters summary {
  list-style: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.advanced-filters summary::-webkit-details-marker { display: none; }
.advanced-filters summary::before {
  content: "▸";
  font-size: 10px;
  transition: transform 0.15s;
}
.advanced-filters[open] summary::before { transform: rotate(90deg); }
.advanced-filters summary:hover { background: var(--bg); color: var(--text); }
.advanced-filters #advancedList { margin-top: 6px; }

.category-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.category-item:hover { background: var(--bg); }
.category-item.active { background: var(--surface); border-color: var(--border); box-shadow: 0 1px 3px rgba(0,0,0,0.04); }

.cat-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  opacity: 0.35;
  transition: opacity 0.15s;
}
.category-item.active .cat-dot { opacity: 1; }

.cat-label {
  flex: 1;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
}
.category-item.active .cat-label { color: var(--text); }

.cat-count {
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 1px 7px;
  border-radius: 20px;
  font-weight: 600;
}

.sidebar-footer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
#resultCount {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}
.credits {
  font-size: 10.5px;
  color: var(--text-faint);
  line-height: 1.5;
  margin: 4px 0 0;
}

/* ---------- Sidebar toggle (mobile) ---------- */
#sidebarToggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 1100;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}

/* ---------- Custom marker icon ---------- */
.custom-marker {
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}
.custom-marker span {
  transform: rotate(45deg);
  font-size: 14px;
}

.custom-marker.marker-highlight {
  border-color: #ffd700;
  box-shadow: 0 0 0 3px #ffd700, 0 0 10px 2px rgba(255, 215, 0, 0.65), 0 2px 6px rgba(0,0,0,0.35);
  animation: highlight-pulse 1.6s ease-in-out infinite;
}
@keyframes highlight-pulse {
  0%, 100% { box-shadow: 0 0 0 3px #ffd700, 0 0 10px 2px rgba(255, 215, 0, 0.65), 0 2px 6px rgba(0,0,0,0.35); }
  50% { box-shadow: 0 0 0 4px #ffd700, 0 0 14px 4px rgba(255, 215, 0, 0.85), 0 2px 6px rgba(0,0,0,0.35); }
}

.marker-cluster-custom {
  background: rgba(29, 53, 87, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.marker-cluster-custom div {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.leaflet-control-attribution {
  font-size: 10px !important;
  background: var(--attribution-bg) !important;
  color: var(--attribution-text) !important;
}
.leaflet-control-attribution a { color: var(--attribution-text) !important; }

/* ---------- Detail panel (right side) ---------- */
#detailPanel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--detail-w);
  max-width: 92vw;
  background: var(--sidebar-bg);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(20, 20, 30, 0.1);
  z-index: 1200;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
#detailPanel.open { transform: translateX(0); }

#detailClose {
  position: sticky;
  top: 14px;
  left: 100%;
  margin: 0 14px 0 0;
  transform: translateX(-100%);
  width: 32px;
  height: 32px;
  border: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  box-shadow: var(--shadow);
  z-index: 2;
}
#detailClose:hover { color: var(--text); }

#detailContent { padding: 4px 24px 28px; }

.detail-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 10px;
  border-radius: 20px;
  color: #fff;
  margin-bottom: 10px;
}
.detail-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  margin: 0 6px 10px 0;
}
.detail-badge.michelin { background: #fff3d6; color: #8a6d1f; }
.detail-badge.emblematico { background: #f1e6df; color: #6b4a35; }
.detail-badge.destacada { background: #e7f0e3; color: #3d5c34; }
.detail-badge.patrocinado { background: linear-gradient(135deg, #ffe8a3, #f0c14b); color: #5a3d00; }

.detail-title {
  font-family: 'Poppins', sans-serif;
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
  line-height: 1.25;
}
.detail-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
}
.detail-rating .stars { letter-spacing: 1px; }
.detail-town {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.4;
}

.detail-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.detail-actions button, .detail-actions a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  transition: all 0.15s;
}
.detail-actions .icon { font-size: 17px; }
.detail-actions .go:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.detail-actions .save.saved { background: #fff8e6; border-color: #f0d78c; color: #8a6d1f; }
.detail-actions .save:hover { background: #fff8e6; border-color: #f0d78c; }

.detail-desc {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-soft);
  margin: 0 0 18px;
}

.detail-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.detail-info-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 13.5px;
  color: var(--text);
}
.detail-info-row .icon { font-size: 15px; width: 18px; flex-shrink: 0; text-align: center; color: var(--text-muted); }
.detail-info-row a { color: var(--accent); text-decoration: none; word-break: break-word; }
.detail-info-row a:hover { text-decoration: underline; }
.detail-info-row .hours-text { white-space: pre-line; line-height: 1.5; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  :root { --sidebar-w: 280px; }
  #sidebarToggle { display: block; }
  #sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }
  #sidebar.open { transform: translateX(0); }
  body:has(#sidebar.open) #sidebarToggle { display: none; }
  #map { left: 0; }
  #detailPanel { width: 100%; max-width: 100%; }
}
