/* ==========================================================================
   Foodism Map - Main Stylesheet
   Modern, responsive UI with Inter font, rounded cards, and soft shadows.
   ========================================================================== */

:root {
  --primary: #ea580c;
  --primary-hover: #c2410c;
  --primary-light: #ffedd5;
  --primary-glow: rgba(234, 88, 12, 0.25);
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-header: #ffffff;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --border-color: #e2e8f0;
  --border-focus: #ea580c;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --sidebar-width: 440px;
  --header-height: 64px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  height: 100vh;
  height: 100dvh; /* dynamic viewport height — correct on mobile browsers */
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------------------
   App Layout
   -------------------------------------------------------------------------- */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* dynamic viewport height — correct on mobile browsers */
  width: 100vw;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.app-header {
  height: var(--header-height);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
  padding: 0 16px;
  z-index: 30;
  box-shadow: var(--shadow-sm);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #f97316, #ea580c);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 2px 8px var(--primary-glow);
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}

/* Ethiopian flag micro-badge pinned to the bottom-right of the logo */
.brand-logo-flag {
  position: absolute;
  right: -6px;
  bottom: -6px;
  font-size: 13px;
  line-height: 1;
  background: #fff;
  border-radius: 9999px;
  padding: 1px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: #fef3c7;
  color: #b45309;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
}

.btn-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-admin {
  background: #f1f5f9;
  color: #334155;
}

.btn-admin:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.mobile-toggle-btn {
  display: none;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 12px;
  font-size: 0.85rem;
  border-radius: var(--radius-md);
  cursor: pointer;
}

/* Attention pulse — invites the user to tap "Show List".
   Automatically removed on first click (see js/app.js).
   Deliberately strong: faster, larger scale + bright expanding ring. */
.mobile-toggle-btn.is-pulsing {
  animation: btn-pulse 1.1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes btn-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(234, 88, 12, 0.7);
    transform: scale(1);
  }
  45% {
    transform: scale(1.1);
  }
  75% {
    box-shadow: 0 0 0 16px rgba(234, 88, 12, 0);
    transform: scale(1);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(234, 88, 12, 0);
    transform: scale(1);
  }
}

/* Respect users who prefer reduced motion — keep the button, drop the pulse */
@media (prefers-reduced-motion: reduce) {
  .mobile-toggle-btn.is-pulsing {
    animation: none;
  }
}

/* --------------------------------------------------------------------------
   API Warning Banner
   -------------------------------------------------------------------------- */
.api-banner {
  background: #fffbeb;
  border-bottom: 1px solid #fef3c7;
  color: #92400e;
  padding: 8px 20px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 25;
}

.api-banner a {
  color: #b45309;
  font-weight: 600;
  text-decoration: underline;
}

.api-banner-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #92400e;
  font-size: 1.1rem;
}

/* --------------------------------------------------------------------------
   Main Content Area (Split Sidebar + Map)
   -------------------------------------------------------------------------- */
.content-area {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--header-height));
  height: calc(100dvh - var(--header-height)); /* dynamic viewport height */
  overflow: hidden;
  position: relative;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 20;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-md);
}

.sidebar-filters-panel {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: #fff;
  overflow-y: auto;
  max-height: 48%;
  flex-shrink: 0;
}

.sidebar-filters-panel::-webkit-scrollbar {
  width: 6px;
}
.sidebar-filters-panel::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.filter-group {
  margin-bottom: 14px;
}

.filter-group:last-child {
  margin-bottom: 0;
}

.sort-and-reset {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-select {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  background-color: #fff;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.sort-select:hover {
  border-color: #cbd5e1;
}

.sort-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.filter-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Label + horizontally-scrollable chips sharing one row (saves vertical space) */
.filter-group--inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-group--inline .filter-label {
  margin-bottom: 0;
  flex-shrink: 0;
}

.filter-group--inline .pill-grid {
  flex: 1 1 auto;
  min-width: 0;
}

.search-input-wrapper {
  position: relative;
}

.text-search-input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  background-color: var(--bg-main);
  transition: all 0.2s ease;
}

.text-search-input:focus {
  outline: none;
  border-color: var(--primary);
  background-color: #fff;
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.filter-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 0.85rem;
}

/* Pills & Checkboxes */
.pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Horizontally-scrolling chip farm (no wrap) — used for cuisine & meal time.
   Scrollbar hidden visually; touch swipe still works. */
.pill-grid--hscroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE / old Edge */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  padding-bottom: 2px; /* room so focus rings / shadows aren't clipped */
}

.pill-grid--hscroll::-webkit-scrollbar {
  display: none; /* Chrome / Safari */
}

.pill-grid--hscroll .pill-item {
  flex: 0 0 auto; /* never shrink — keep clean, tappable targets */
  padding: 6px 12px;
  white-space: nowrap;
}

.pill-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 500;
  background: #f1f5f9;
  color: var(--text-muted);
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.pill-item:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.pill-item input[type="checkbox"] {
  display: none;
}

.pill-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: #fdba74;
  font-weight: 600;
}

.pill-count {
  font-size: 0.7rem;
  opacity: 0.8;
  background: rgba(0,0,0,0.06);
  padding: 1px 5px;
  border-radius: var(--radius-full);
}

.pill-item.active .pill-count {
  background: rgba(234, 88, 12, 0.15);
}

/* Reset action (sort dropdown removed) */
.sort-and-reset {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sort-and-reset .btn-reset-filters {
  margin-left: auto; /* lone action — stays right-aligned */
}

.btn-reset-filters {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.btn-reset-filters:hover {
  background: var(--primary-light);
}

/* --------------------------------------------------------------------------
   Restaurant List Section
   -------------------------------------------------------------------------- */
.sidebar-list-header {
  padding: 10px 20px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.restaurant-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.restaurant-list::-webkit-scrollbar {
  width: 6px;
}
.restaurant-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* --------------------------------------------------------------------------
   Miniature Preview Card (mobile collapsed sheet) — hidden on desktop
   -------------------------------------------------------------------------- */
.sidebar-mini {
  display: none;
}

/* --------------------------------------------------------------------------
   Restaurant Card
   -------------------------------------------------------------------------- */
.restaurant-card {
  display: flex;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  box-shadow: var(--shadow-sm);
}

.restaurant-card:hover {
  transform: translateY(-2px);
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
}

.restaurant-card.active {
  border-color: var(--primary);
  background-color: #fffaf5;
  box-shadow: 0 0 0 2px var(--primary-glow), var(--shadow-md);
}

.card-thumbnail-wrap {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  background: #f1f5f9;
}

.card-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.restaurant-card:hover .card-thumbnail {
  transform: scale(1.05);
}

.card-badges-overlay {
  position: absolute;
  bottom: 4px;
  left: 4px;
  display: flex;
  gap: 4px;
}

.mini-badge {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 2px;
}

.card-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
}

.card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-rating {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #d97706;
}

.card-address {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.tag-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: #f1f5f9;
  color: #475569;
  text-transform: capitalize;
}

.tag-badge.tag-burger { background: #fee2e2; color: #991b1b; }
.tag-badge.tag-pizza { background: #ffedd5; color: #9a3412; }
.tag-badge.tag-pasta { background: #fef3c7; color: #92400e; }
.tag-badge.tag-ethiopian { background: #ecfccb; color: #3f6212; }
.tag-badge.tag-chicken { background: #fef08a; color: #854d0e; }
.tag-badge.tag-coffee { background: #f3e8ff; color: #6b21a8; }
.tag-badge.tag-dessert { background: #fce7f3; color: #9d174d; }
.tag-badge.tag-indian { background: #e0e7ff; color: #3730a3; }
.tag-badge.tag-korean { background: #ccfbf1; color: #115e59; }

.card-distance {
  font-size: 0.72rem;
  color: var(--primary);
  font-weight: 600;
}

.missing-coord-indicator {
  font-size: 0.7rem;
  color: #b45309;
  background: #fef3c7;
  padding: 1px 5px;
  border-radius: 4px;
  display: inline-block;
  margin-top: 2px;
}

/* --------------------------------------------------------------------------
   Empty State
   -------------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
  display: block;
}

.empty-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

/* --------------------------------------------------------------------------
   Map Container
   -------------------------------------------------------------------------- */
.map-container {
  flex: 1;
  height: 100%;
  position: relative;
  background: #e5e3df;
}

#map {
  width: 100%;
  height: 100%;
}

/* Map Overlays & Floating Controls */
.map-floating-controls {
  position: absolute;
  bottom: 24px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}

.btn-map-control {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.btn-map-control:hover {
  background: #f8fafc;
  transform: scale(1.05);
}

.btn-map-control:active {
  transform: scale(0.95);
}

/* Locating state for the floating 📍 control (Google Maps-style spinner) */
.btn-map-control.is-locating {
  color: transparent;
  font-size: 0;
  pointer-events: none;
}

.btn-map-control.is-locating::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: locate-spin 0.8s linear infinite;
}

@keyframes locate-spin {
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   Location Status Toast (finding / denied / unavailable + Retry)
   -------------------------------------------------------------------------- */
.map-status-toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: min(480px, calc(100% - 120px));
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.94);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.35;
  box-shadow: var(--shadow-lg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.map-status-toast[hidden] {
  display: none;
}

.map-status-toast.is-error {
  background: rgba(153, 27, 27, 0.96);
}

.map-status-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.map-status-text {
  flex: 1 1 auto;
  min-width: 0;
}

.map-status-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: locate-spin 0.8s linear infinite;
}

.map-status-retry {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 11px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.map-status-retry:hover {
  background: rgba(255, 255, 255, 0.24);
}

.map-status-retry[hidden] {
  display: none;
}

.map-status-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
}

.map-status-close:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .btn-map-control.is-locating::after,
  .map-status-spinner {
    animation: none;
  }
}

/* Fallback Map Notice */
.fallback-map-notice {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10;
  box-shadow: var(--shadow-lg);
}

/* --------------------------------------------------------------------------
   Google Maps InfoWindow Custom Styling
   -------------------------------------------------------------------------- */
.gm-style .gm-style-iw-c {
  padding: 0 !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-xl) !important;
  overflow: hidden !important;
  max-width: 320px !important;
}

.gm-style .gm-style-iw-d {
  overflow: hidden !important;
  padding: 0 !important;
}

.info-window-card {
  width: 290px;
  display: flex;
  flex-direction: column;
  background: #fff;
  font-family: inherit;
}

.info-window-image-wrap {
  width: 100%;
  height: 140px;
  position: relative;
  background: #f1f5f9;
}

.info-window-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.info-window-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(15, 23, 42, 0.8);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.info-window-body {
  padding: 12px 14px 14px;
}

.info-window-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.info-window-address {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.3;
}

.info-window-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}

.info-window-actions {
  display: flex;
  gap: 6px;
}

.btn-view-details {
  flex: 1;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}

.btn-view-details:hover {
  background: var(--primary-hover);
}

.btn-directions {
  background: #f1f5f9;
  color: #334155;
  border: none;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.btn-directions:hover {
  background: #e2e8f0;
}

/* --------------------------------------------------------------------------
   Lightbox Modal
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

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

.lightbox-dialog {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.open .lightbox-dialog {
  transform: scale(1);
}

.lightbox-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lightbox-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lightbox-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
}

.lightbox-close-btn {
  background: #f1f5f9;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.lightbox-close-btn:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.lightbox-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  max-height: calc(90vh - 60px);
}

.lightbox-media-panel {
  flex: 1.3;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.hero-media-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 320px;
  overflow: hidden;
}

.hero-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
}

.video-embed-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.video-embed-container iframe,
.video-embed-container video {
  width: 100%;
  height: 100%;
  border: none;
}

.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(4px);
  color: #fff;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 5;
}

.lightbox-nav-btn:hover {
  background: rgba(255, 255, 255, 0.4);
}

.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }

.lightbox-thumbnail-strip {
  height: 76px;
  background: rgba(15, 23, 42, 0.95);
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  overflow-x: auto;
  flex-shrink: 0;
}

.lightbox-thumbnail-strip::-webkit-scrollbar {
  height: 4px;
}
.lightbox-thumbnail-strip::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

.thumb-item {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  opacity: 0.6;
  border: 2px solid transparent;
  flex-shrink: 0;
  transition: all 0.15s;
}

.thumb-item:hover {
  opacity: 0.9;
}

.thumb-item.active {
  opacity: 1;
  border-color: var(--primary);
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Lightbox Details Panel */
.lightbox-details-panel {
  flex: 0.9;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #fff;
}

.details-section h4 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.details-description {
  font-size: 0.92rem;
  line-height: 1.6;
  color: #334155;
  background: #f8fafc;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

/* ===== About & Highlights — formatted menu table + notes ===== */
/* Transparent-outline table: item on the left, price on the right */
.about-menu-table {
  width: 100%;
  border-collapse: collapse;
  border: none; /* transparent outline */
}
.about-menu-table td {
  border: none;
  padding: 4px 0;
  vertical-align: bottom;
}
.about-item {
  text-align: left;
  font-weight: 600;
  color: #1e293b;
  width: 1%;            /* shrink to content so the price hugs the right */
  white-space: nowrap;  /* keep each dish on a single line (no vertical stacking) */
}
.about-item--full {
  width: auto;
}
/* Dotted leader between item and price */
.about-leader {
  border-bottom: 1px dotted #cbd5e1;
  padding: 0 8px;
}
/* Price justified to the right, cash green */
.about-price {
  text-align: right;
  font-weight: 700;
  color: #15803d; /* cash green */
  white-space: nowrap;
  width: 1%;
}

.about-notes {
  margin: 10px 0 0;
  padding: 10px 0 0;
  list-style: none;
  border-top: 1px dashed var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.about-notes li {
  font-size: 0.86rem;
  line-height: 1.5;
  color: #475569;
}

.about-notes a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  word-break: break-all;
}
.about-notes a:hover {
  text-decoration: underline;
}

.about-empty {
  color: #94a3b8;
  font-style: italic;
}

.details-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: #334155;
}

.details-meta-row a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.details-meta-row a:hover {
  text-decoration: underline;
}

.details-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.btn-directions-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: background 0.15s;
}

.btn-directions-primary:hover {
  background: var(--primary-hover);
}

/* --------------------------------------------------------------------------
   Responsive Design
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .app-header {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    padding-top: env(safe-area-inset-top);
    gap: 10px;
  }

  .mobile-toggle-btn {
    display: inline-flex;
    padding: 10px 14px; /* larger touch target */
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .content-area {
    position: relative;
  }

  /* Bottom-sheet style sidebar */
  .sidebar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 72%;
    padding-bottom: env(safe-area-inset-bottom);
    border-right: none;
    border-top: 1px solid var(--border-color);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.15);
    transform: translateY(calc(100% - 104px)); /* Peek mode — handle + list header + top of first card */
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.mobile-open {
    transform: translateY(0);
  }

  .sidebar-drag-handle {
    width: 44px;
    height: 5px;
    background: #cbd5e1;
    border-radius: 3px;
    margin: 10px auto 6px;
    cursor: grab;
    flex-shrink: 0;
  }

  /* Filters stay fixed at the top of the sheet (no internal scrolling) */
  .sidebar-filters-panel {
    padding: 12px 14px;
    flex-shrink: 0;
    max-height: none;
    overflow: visible;
  }

  /* List header stays fixed under the filters */
  .sidebar-list-header {
    flex-shrink: 0;
  }

  /* Only the restaurant cards scroll vertically in the remaining space */
  .restaurant-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* --- Selected state: collapse sheet into a miniature preview card --- */
  .sidebar.is-collapsed {
    height: 23%; /* ~20–25% of viewport */
    transform: translateY(0);
  }

  .sidebar.is-collapsed .sidebar-filters-panel,
  .sidebar.is-collapsed .sidebar-list-header,
  .sidebar.is-collapsed .restaurant-list {
    display: none;
  }

  .sidebar.is-collapsed .sidebar-mini {
    display: flex;
  }

  /* Miniature preview card */
  .sidebar-mini {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
  }

  .sidebar-mini-thumb {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
    background: #f1f5f9;
  }

  .sidebar-mini-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .sidebar-mini-info {
    flex: 1 1 auto;
    min-width: 0;
  }

  .sidebar-mini-name {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sidebar-mini-address {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
  }

  .sidebar-mini-expand {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: #fff;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px var(--primary-glow);
  }

  .sidebar-mini-expand:active {
    transform: scale(0.94);
  }

  /* Keep the floating map control clear of the taller sheet peek */
  .map-floating-controls {
    bottom: calc(118px + env(safe-area-inset-bottom));
    right: max(14px, env(safe-area-inset-right));
  }

  /* Keep the location toast fully visible above the bottom sheet / controls */
  .map-status-toast {
    top: 84px;
    bottom: auto;
    left: max(14px, env(safe-area-inset-left));
    right: max(14px, env(safe-area-inset-right));
    transform: none;
    width: auto;
    max-width: none;
  }

  .btn-map-control {
    width: 46px;
    height: 46px;
    font-size: 1.2rem;
    box-shadow: var(--shadow-lg);
  }

  /* Full-height, edge-to-edge lightbox on phones */
  .modal-overlay {
    padding: 0;
  }

  .lightbox-dialog {
    max-width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .lightbox-body {
    flex-direction: column;
    max-height: none;
  }

  /* --- Image Section Scaling: cap the carousel, let the image cover --- */
  .lightbox-media-panel {
    flex: none;
    max-height: 40vh;
    max-height: 40dvh;
    min-height: 0;
  }

  .hero-media-wrapper {
    flex: 1 1 auto;
    min-height: 0;
  }

  .hero-image {
    width: 100%;
    max-height: 40vh;
    max-height: 40dvh;
    object-fit: cover;
  }

  /* --- Content Scrolling Partition: details scroll independently --- */
  .lightbox-details-panel {
    flex: none;
    height: calc(100% - 40vh);
    height: calc(100% - 40dvh);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
  }

  .lightbox-header {
    padding-top: max(14px, env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}
