:root {
  --green-900: #1b3a1f;
  --green-700: #33691e;
  --green-500: #558b2f;
  --green-300: #8bc34a;
  --cream: #f7f6f0;
  --ink: #1f2419;
  --muted: #6b7266;
  --card: #ffffff;
  --red: #c0392b;
  --amber: #b7791f;
  --shadow: 0 2px 10px rgba(27, 58, 31, 0.12);
  --shadow-lg: 0 8px 30px rgba(27, 58, 31, 0.22);
  --sidebar-w: 370px;
  --topbar-h: auto;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  font-family: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  color: var(--ink); background: var(--cream);
  -webkit-text-size-adjust: 100%;
}

#app { display: flex; height: 100vh; width: 100vw; overflow: hidden; }

/* ---------- Sidebar ---------- */
#sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w); height: 100%;
  background: var(--cream); border-right: 1px solid rgba(27, 58, 31, 0.1);
  display: flex; flex-direction: column; overflow: hidden;
}

#topbar {
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(27, 58, 31, 0.08);
  position: relative;
}
.brand-row { display: flex; align-items: center; justify-content: space-between; }
.brand { margin: 0; font-size: 25px; font-weight: 800; letter-spacing: -0.5px; color: var(--green-700); }
.brand span { color: var(--green-300); }

#list-toggle {
  display: none; /* desktop hidden */
  border: none; background: var(--green-700); color: #fff;
  padding: 10px 14px; border-radius: 10px; font-weight: 700; font-size: 14px; cursor: pointer;
  align-items: center; justify-content: center; gap: 6px;
}
#list-toggle .chev { display: inline-block; transition: transform 0.2s; }

/* Day selector */
.day-selector {
  display: flex; align-items: center; gap: 8px; margin-top: 12px;
}
.day-arrow {
  width: 38px; height: 38px; flex-shrink: 0;
  border: 1px solid rgba(27,58,31,0.15); background: var(--card);
  border-radius: 10px; font-size: 20px; line-height: 1; cursor: pointer; color: var(--green-700);
}
.day-arrow:hover { background: #fff; border-color: var(--green-300); }
.day-label {
  flex: 1; height: 38px; border: 1px solid rgba(27,58,31,0.15); background: var(--card);
  border-radius: 10px; font-size: 15px; font-weight: 700; color: var(--ink); cursor: pointer;
  padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.day-label:hover { border-color: var(--green-300); }

.day-popover {
  position: absolute; z-index: 30; top: 100%; left: 18px; right: 18px;
  margin-top: 6px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 12px;
}

.locate-btn {
  margin-top: 10px; width: 100%; padding: 10px 14px; border: none; border-radius: 10px;
  background: var(--green-700); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}
.locate-btn:hover { background: var(--green-900); }

#place-list { list-style: none; margin: 0; padding: 10px; overflow-y: auto; flex: 1; }

.place-card {
  display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 12px;
  background: var(--card); box-shadow: var(--shadow); margin-bottom: 10px; cursor: pointer;
  border: 2px solid transparent; border-left: 4px solid transparent; transition: transform 0.12s, border-color 0.12s;
}
.place-card:hover { transform: translateY(-1px); }
.place-card.active { border-color: var(--green-300); }
.place-card.status-open { border-left-color: var(--green-500); }
.place-card.status-closed { border-left-color: var(--red); }

.place-card img {
  width: 52px; height: 52px; border-radius: 12px; object-fit: cover; flex-shrink: 0; background: var(--green-300);
}
.place-card .info { min-width: 0; flex: 1; }
.place-card .info h3 { margin: 0 0 2px; font-size: 16px; font-weight: 700; }
.place-card .addr {
  margin: 0; font-size: 12.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.place-card .status { margin: 4px 0 0; font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.status-open .status { color: var(--green-700); }
.status-open .status-dot { background: var(--green-500); }
.status-closed .status { color: var(--red); }
.status-closed .status-dot { background: var(--red); }
.status-unknown .status { color: var(--muted); }

#sidebar-footer { padding: 9px 18px; border-top: 1px solid rgba(27,58,31,0.08); font-size: 12px; color: var(--muted); }

/* ---------- Map ---------- */
#map-wrap { position: relative; flex: 1; height: 100%; }
#map { width: 100%; height: 100%; }
.map-error {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; padding: 24px; background: var(--cream);
}
.map-error code { background: rgba(27,58,31,0.08); padding: 2px 6px; border-radius: 6px; }
.map-status {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(31,36,25,0.9); color: #fff; padding: 8px 14px; border-radius: 999px;
  font-size: 13px; box-shadow: var(--shadow); z-index: 5;
}

.logo-pin {
  width: 42px; height: 42px; border-radius: 50%; border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35); background-size: cover; background-position: center;
  cursor: pointer; transition: transform 0.12s;
}
.logo-pin:hover { transform: scale(1.12); }

/* ---------- Detail panel ---------- */
.detail {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  width: min(440px, calc(100vw - 32px)); background: var(--card);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 20px; z-index: 40; animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
#detail-close {
  position: absolute; top: 12px; right: 12px; border: none; background: rgba(27,58,31,0.06);
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 14px; color: var(--ink);
}
.detail-head { display: flex; gap: 14px; align-items: center; }
.detail-head img { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; background: var(--green-300); }
.detail-head h2 { margin: 0 0 4px; font-size: 20px; }
.detail-status { font-size: 12.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.detail-status.status-open { background: rgba(85,139,47,0.15); color: var(--green-700); }
.detail-status.status-closed { background: rgba(192,57,43,0.12); color: var(--red); }
.detail-rows { margin: 16px 0; display: grid; gap: 8px; }
.detail-row { display: flex; gap: 10px; font-size: 14px; }
.detail-row .label { width: 96px; color: var(--muted); flex-shrink: 0; }
.detail-actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.detail-actions a { flex: 1; min-width: 90px; text-align: center; text-decoration: none; padding: 11px 12px; border-radius: 10px; font-weight: 600; font-size: 14px; }
.btn-ig { background: linear-gradient(45deg, #f09433, #dc2743, #bc1888); color: #fff; }
.btn-web { background: var(--green-700); color: #fff; }
.btn-dir { background: rgba(27,58,31,0.08); color: var(--green-900); }

/* ---------- Calendar (shared) ---------- */
.cal { width: 100%; user-select: none; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-weight: 700; font-size: 15px; }
.cal-nav { border: none; background: rgba(27,58,31,0.06); width: 30px; height: 30px; border-radius: 8px; font-size: 17px; cursor: pointer; color: var(--green-700); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow-cell { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; font-weight: 700; }
.cal-cell {
  aspect-ratio: 1 / 1; border: none; background: transparent; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--ink); display: flex; align-items: center; justify-content: center; position: relative;
}
.cal-cell:hover { background: rgba(27,58,31,0.07); }
.cal-cell.is-today { flex-direction: column; gap: 0; font-weight: 700; color: var(--green-700); }
.cal-cell.is-today .cal-num { line-height: 1; }
.cal-today-tag { font-size: 6.5px; font-weight: 800; letter-spacing: 0.5px; color: #9aa39a; line-height: 1; margin-top: 1px; }
.cal-cell.is-selected .cal-today-tag { color: rgba(255, 255, 255, 0.85); }
.cal-cell.is-selected { background: var(--green-700); color: #fff; }
.cal-empty { cursor: default; }
.cal-cell.has-dot::after {
  content: ''; position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--dot, var(--green-500));
}
.cal-cell.is-selected.has-dot::after { background: #fff; }
.cal-foot { margin-top: 8px; text-align: right; }
.cal-today { border: none; background: transparent; color: var(--green-700); font-weight: 700; cursor: pointer; font-size: 13px; }

/* distance chip in list cards */
.place-card .info h3 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.place-card .dist { font-size: 11.5px; font-weight: 600; color: var(--muted); flex-shrink: 0; }

/* Menu dropdown in detail panel */
.menu-toggle {
  width: 100%; margin-top: 10px; padding: 11px 14px; border: 1px solid rgba(27,58,31,0.15);
  background: var(--card); border-radius: 10px; font-weight: 700; font-size: 14px; color: var(--green-900);
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.menu-toggle:hover { border-color: var(--green-300); }
.menu-toggle .chev { transition: transform 0.2s; }
.menu-toggle.open .chev { transform: rotate(180deg); }

/* Hours block: today's exact date + "see more dates" expander */
.hours-block { margin: 14px 0 4px; }
.hours-today { font-size: 14.5px; }
.ht-date { font-weight: 700; color: var(--ink); }
.ht-time { font-weight: 600; }
.ht-time.status-open { color: var(--green-700); }
.ht-time.status-closed { color: var(--red); }
.ht-time.status-unknown { color: var(--muted); }
.more-dates-toggle {
  display: block; width: 100%; margin: 8px 0 0; padding: 4px; border: none; background: none;
  color: var(--muted); font-size: 12px; letter-spacing: 0.5px; cursor: pointer; text-align: center;
}
.more-dates-toggle:hover { color: var(--green-700); }
.more-dates-panel { margin-top: 6px; max-height: 220px; overflow-y: auto; border-top: 1px dotted rgba(27,58,31,0.15); padding-top: 6px; }
.date-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 4px 2px; }
.date-row .dr-date { color: var(--ink); }
.date-row .dr-time { color: var(--green-700); font-weight: 600; white-space: nowrap; }

/* Menu items */
.menu-panel { margin-top: 10px; max-height: 320px; overflow-y: auto; }
.menu-item { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid rgba(27,58,31,0.08); }
.menu-item:last-child { border-bottom: none; }
.menu-item-img { width: 60px; height: 60px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: #eef0e8; }
.menu-item-info { flex: 1; min-width: 0; }
.menu-item-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.menu-item-name { font-weight: 700; font-size: 14.5px; }
.menu-item-price { font-weight: 700; color: var(--green-700); white-space: nowrap; }
.menu-item-desc { margin: 3px 0 0; font-size: 13px; color: var(--muted); line-height: 1.35; }

.hidden { display: none !important; }

/* ---------- Mobile: header + dropdown ---------- */
@media (max-width: 760px) {
  #app { display: block; position: relative; }
  #map-wrap { position: absolute; inset: 0; height: 100%; width: 100%; }

  /* sidebar becomes a top header sheet overlaying the map.
     overflow visible so the calendar popover isn't clipped by the header. */
  #sidebar {
    position: absolute; z-index: 20; top: 0; left: 0; right: 0;
    width: 100%; min-width: 0; height: auto; max-height: calc(100% - 16px);
    background: var(--cream); border-right: none;
    border-bottom: 1px solid rgba(27,58,31,0.12);
    box-shadow: var(--shadow); border-radius: 0 0 16px 16px;
    overflow: visible;
  }
  /* "Places" spans the header, below the day selector */
  #list-toggle { display: flex; width: 100%; margin-top: 10px; }
  #sidebar.list-open #list-toggle .chev { transform: rotate(180deg); }

  /* list collapses by default; expands as a dropdown */
  #place-list {
    max-height: 0; padding: 0 10px; overflow: hidden;
    transition: max-height 0.25s ease, padding 0.25s ease;
  }
  #sidebar.list-open #place-list {
    max-height: 60vh; padding: 10px; overflow-y: auto;
  }
  #sidebar-footer { display: none; }
  #sidebar.list-open #sidebar-footer { display: block; }

  .day-popover { left: 12px; right: 12px; }
  .detail { bottom: 12px; }
}
