/* style.css — Nearby PWA */

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

:root {
  --bg: #F7F5F0;
  --text: #1A1A18;
  --text-secondary: #8A8680;
  --border: #E8E4DD;
  --tab-bg: #EDEAE4;
  --tab-active-bg: #FFFFFF;
  --eat: #C85A3D;
  --drink: #6B5B8A;
  --see: #2D7D9A;
  --font-serif: 'Source Serif 4', 'Georgia', serif;
  --font-sans: 'Instrument Sans', 'Inter', -apple-system, system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ── App Shell ── */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* ── Header ── */
.header {
  padding: 12px 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.header h1 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

#trip-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

#trip-selector select {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  max-width: 160px;
  appearance: none;
  cursor: pointer;
}

/* ── GPS Status ── */
.gps-bar {
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.gps-dot {
  font-size: 10px;
  line-height: 1;
}

.gps-label {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ── Neighborhood Bar ── */
.neighborhood-bar {
  display: none;
  padding: 4px 16px 2px;
}

.neighborhood-label {
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 400;
  font-style: italic;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

/* ── Auto-Trip Bar ── */
.auto-trip-bar {
  display: none;
  padding: 6px 16px;
  margin: 0 16px 4px;
  background: #FFF8E1;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
  align-items: center;
  gap: 8px;
}

.auto-trip-text {
  flex: 1;
}

.auto-trip-switch {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--see);
  background: none;
  border: 1px solid var(--see);
  border-radius: 4px;
  padding: 3px 10px;
  cursor: pointer;
}

.auto-trip-dismiss {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 2px;
  padding: 8px 16px;
  margin-bottom: 4px;
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 4px;
  background: var(--tab-bg);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}

.tab:first-child { border-radius: 6px 2px 2px 6px; }
.tab:last-child { border-radius: 2px 6px 6px 2px; }

.tab.active {
  background: var(--tab-active-bg);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.tab-label { font-weight: 500; }
.tab-count { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Place List ── */
.place-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px;
  -webkit-overflow-scrolling: touch;
}

.place-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.2s;
}

.place-item.closed {
  opacity: 0.45;
}

.place-info {
  flex: 1;
  min-width: 0;
}

.place-name-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.place-name {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  line-height: 1.3;
}

.place-name:active {
  opacity: 0.6;
}

.place-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.35;
}

.place-city {
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.7;
}

.place-notes {
  font-size: 11px;
  font-style: italic;
  color: var(--text-secondary);
  margin-top: 2px;
}

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

.tag {
  font-size: 10px;
  color: var(--text-secondary);
  background: var(--tab-bg);
  padding: 1px 6px;
  border-radius: 3px;
}

/* ── Proximity Column ── */
.place-proximity {
  text-align: right;
  flex-shrink: 0;
  min-width: 64px;
  text-decoration: none;
  padding: 2px 0;
}

.place-proximity:active {
  opacity: 0.6;
}

.place-star {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px 2px 0;
  flex-shrink: 0;
  align-self: flex-start;
  color: var(--border);
  transition: color 0.15s;
  line-height: 1.3;
}

.place-star.starred {
  color: #E6A817;
}

.place-star:active {
  transform: scale(1.2);
}

.place-edit {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 2px 4px 8px;
  flex-shrink: 0;
  align-self: flex-start;
  opacity: 0.5;
}

.place-edit:active {
  opacity: 1;
}

.place-delete {
  background: none;
  border: none;
  color: var(--border);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 0 4px 8px;
  flex-shrink: 0;
  align-self: flex-start;
  transition: color 0.15s;
}

.place-delete:active {
  color: var(--eat);
}

.place-time {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 3px;
}

.time-value {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.time-mode {
  font-size: 11px;
}

.place-distance {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 1px;
}

/* ── Status Badges ── */
.status-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 5px;
  border-radius: 3px;
}

.status-badge.open {
  color: #2E7D32;
  background: #E8F5E9;
}

.status-badge.closed {
  color: #9E9E9E;
  background: #F5F5F5;
}

/* ── Far Divider ── */
.far-divider {
  padding: 16px 0 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

/* ── Empty State ── */
.empty-state {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ── Bottom Bar ── */
.bottom-bar {
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  display: flex;
  justify-content: center;
}

.btn-primary {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--tab-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 24px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:active {
  background: var(--border);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
}

/* ── Modal ── */
#modal-container {
  display: none;
}

#modal-container.visible {
  display: block;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal {
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding-bottom: var(--safe-bottom);
}

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

.modal-header h2 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px 8px;
}

.modal-tabs {
  display: flex;
  gap: 0;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-tab {
  flex: 1;
  padding: 8px 4px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.modal-tab.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  max-height: 60vh;
  -webkit-overflow-scrolling: touch;
}

/* ── Import ── */
.import-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.import-search input,
.import-paste textarea {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.import-paste textarea {
  resize: vertical;
  min-height: 120px;
}

.import-cat-select {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.import-cat-select select {
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}

.import-progress {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.import-results {
  margin-top: 12px;
}

.import-review {
  font-size: 13px;
}

.review-item {
  padding: 4px 0;
  color: var(--text-secondary);
}

.review-item.error {
  color: var(--eat);
}

.import-review .btn-primary {
  margin-top: 12px;
  width: 100%;
}

.search-results {
  margin-top: 8px;
}

.search-result-item {
  padding: 8px 0;
}

.search-result-name {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 8px;
}

.search-result-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-result-actions select,
.search-result-actions input {
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}

.search-result-actions input {
  flex: 1;
}

.loading {
  padding: 12px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Trip Manager ── */
.trip-list {
  margin-bottom: 16px;
}

.trip-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.trip-name {
  font-size: 14px;
}

.trip-delete {
  color: var(--eat);
}

.btn-share {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--see);
  border: none;
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 16px;
  cursor: pointer;
}

.btn-share:active {
  opacity: 0.8;
}

.trip-add {
  display: flex;
  gap: 8px;
}

.trip-add input {
  flex: 1;
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

/* ── Edit Form ── */
.edit-field {
  margin-bottom: 12px;
}

.edit-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.edit-field input,
.edit-field textarea,
.edit-field select {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.edit-field textarea {
  resize: vertical;
  min-height: 60px;
}

.edit-hours-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.edit-hours-row input {
  width: 80px;
}

.edit-hours-row span {
  color: var(--text-secondary);
}

.app-version {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.import-file input[type="file"] {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Scrollbar (subtle) ── */
.place-list::-webkit-scrollbar { width: 4px; }
.place-list::-webkit-scrollbar-track { background: transparent; }
.place-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
