:root {
  --orange: #FF9500;
  --orange-light: #FFF3E0;
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --text: #000000;
  --text-secondary: #6C6C70;
  --border: #E5E5EA;
  --green: #34C759;
  --red: #FF3B30;
  --radius: 12px;
  --header-h: 100px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1C1C1E;
    --text: #FFFFFF;
    --text-secondary: #8E8E93;
    --border: #38383A;
    --orange-light: #2C1A00;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}

/* ── Header ─────────────────────────────────────── */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
}

.header-title {
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  padding: 12px 16px 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tabs {
  display: flex;
  padding: 4px 16px 8px;
  gap: 8px;
}

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

.tab svg { width: 16px; height: 16px; }

/* ── Filtres ─────────────────────────────────────── */
.list-filters {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 8px;
  border-bottom: 1px solid var(--border);
}

.search-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  width: 16px; height: 16px;
  color: var(--text-secondary);
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 8px 32px 8px 34px;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  -webkit-appearance: none;
}

#search-input::placeholder { color: var(--text-secondary); }

.search-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
}

.search-clear.hidden { display: none; }

.filter-open {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.filter-open input[type="checkbox"] { display: none; }

.filter-open-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  user-select: none;
}

.filter-open:has(input:checked) {
  background: var(--green);
}

.filter-open:has(input:checked) .filter-open-label {
  color: white;
}

.tab.active {
  background: var(--orange);
  color: white;
}

/* ── Main ────────────────────────────────────────── */
main {
  margin-top: var(--header-h);
  height: calc(100dvh - var(--header-h));
  overflow: hidden;
}

.view { display: none; height: 100%; }
.view.active { display: block; }

/* ── Liste ───────────────────────────────────────── */
#list-view { overflow-y: auto; -webkit-overflow-scrolling: touch; }

#bar-list { padding: 12px 16px calc(12px + var(--safe-bottom)) 16px; display: flex; flex-direction: column; gap: 10px; }

.bar-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  gap: 12px;
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-user-select: none;
}

.bar-card:active { opacity: 0.7; }
.bar-card.closed { opacity: 0.55; }

.bar-emoji {
  font-size: 32px;
  width: 44px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
  padding-top: 2px;
}

.bar-emoji.grayscale { filter: grayscale(1); }

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

.bar-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bar-name .fav-star { color: #FFD700; font-size: 13px; }

.fav-btn-list {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 6px;
  color: var(--text-secondary);
  flex-shrink: 0;
  line-height: 1;
}

.fav-btn-list.active { color: #FFD700; }

.bar-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-sun {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.bar-sun.sunny { color: var(--orange); }

.bar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.badge-open { background: rgba(52,199,89,0.15); color: var(--green); }
.badge-closed { background: rgba(255,59,48,0.15); color: var(--red); }
.badge-shelter { background: rgba(0,122,255,0.12); color: #007AFF; }

.bar-distance {
  font-size: 12px;
  color: #007AFF;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ── Carte ───────────────────────────────────────── */
#map-view { position: relative; isolation: isolate; }
#map { width: 100%; height: 100%; }

.beer-marker {
  font-size: 28px;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.beer-marker.grayscale { filter: grayscale(1) drop-shadow(0 1px 2px rgba(0,0,0,0.2)); }
.beer-marker.selected { transform: scale(1.4); z-index: 1000 !important; }

/* ── Carte popup résumé ──────────────────────────── */
.map-card {
  position: absolute;
  bottom: 24px;
  left: 12px;
  right: 12px;
  z-index: 1000;
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
  transition: transform 0.25s cubic-bezier(0.32,0.72,0,1), opacity 0.25s;
}

.map-card.hidden {
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
}

.map-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.map-card-emoji { font-size: 28px; flex-shrink: 0; }
.map-card-emoji.grayscale { filter: grayscale(1); }

.map-card-name {
  font-size: 17px;
  font-weight: 700;
  flex: 1;
  line-height: 1.2;
}

.map-card-close {
  background: var(--border);
  border: none;
  border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.map-card-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.map-card-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.map-card-row-icon { width: 20px; text-align: center; flex-shrink: 0; }
.map-card-row-text { color: var(--text-secondary); }
.map-card-row-text.sunny { color: var(--orange); font-weight: 500; }
.map-card-row-text.open  { color: var(--green); font-weight: 500; }
.map-card-row-text.closed { color: var(--red); font-weight: 500; }

.map-card-detail {
  width: 100%;
  padding: 11px;
  background: var(--orange);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

/* ── Vue détail ──────────────────────────────────── */
#detail-view {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}

.sheet-handle-bar {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 10px 0 6px;
  display: flex;
  justify-content: center;
  z-index: 1;
}

.sheet-handle {
  width: 36px; height: 5px;
  background: var(--border);
  border-radius: 3px;
}

/* ── Détail ──────────────────────────────────────── */
#detail-content { padding: 0 16px calc(16px + var(--safe-bottom)); }

.detail-back {
  padding: 12px 16px 0;
}

.back-btn {
  background: none;
  border: none;
  color: var(--orange);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
}

.detail-header { margin-bottom: 12px; }

.detail-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-fav-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  flex-shrink: 0;
}

.detail-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* Chips jours */
.day-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 2px 0 8px;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
}

.day-chips::-webkit-scrollbar { display: none; }

.day-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--border);
  border: none;
  cursor: pointer;
  text-align: center;
}

.day-chip.active { background: var(--orange); color: white; }

.day-chip-label { font-size: 12px; font-weight: 500; display: block; }
.day-chip-date { font-size: 11px; color: var(--text-secondary); display: block; }
.day-chip.active .day-chip-date { color: rgba(255,255,255,0.8); }

/* Timeline soleil */
.sun-section { margin: 12px 0; }

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.timeline-wrap { position: relative; }

.timeline-bar {
  height: 28px;
  background: var(--border);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  margin-bottom: 4px;
}

.timeline-segment {
  position: absolute;
  top: 0; bottom: 0;
  background: linear-gradient(90deg, #FFD60A, #FF9500);
  border-radius: 4px;
}

.timeline-now {
  position: absolute;
  top: -4px; bottom: -4px;
  width: 2px;
  background: white;
  border-radius: 1px;
  box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-secondary);
  padding: 0 1px;
}

/* Plages soleil */
.sun-periods { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.sun-period {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 10px;
  padding: 12px;
}

.sun-period-icon { font-size: 26px; }

.sun-period-time { font-size: 16px; font-weight: 600; }
.sun-period-dur { font-size: 13px; color: var(--orange); margin-top: 1px; }

.no-sun {
  text-align: center;
  padding: 32px 0;
  color: var(--text-secondary);
}

.no-sun-emoji { font-size: 48px; display: block; margin-bottom: 8px; }

.sun-total {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 12px;
  background: var(--orange-light);
  border-radius: 10px;
  margin-top: 8px;
  color: var(--orange);
}

/* Horaires */
.hours-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 16px;
}

.hours-row {
  display: flex;
  align-items: flex-start;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.hours-row:last-child { border-bottom: none; }
.hours-row.today .hours-day,
.hours-row.today .hours-time { color: var(--orange); font-weight: 600; }

.hours-day { width: 110px; font-size: 14px; flex-shrink: 0; }
.hours-time { font-size: 14px; color: var(--text-secondary); }
.hours-closed { color: var(--text-secondary); font-size: 14px; }

/* Loading */
.loading-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-secondary);
}

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

/* ── Skeleton chargement ─────────────────────────── */
.skeleton-block {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Feedback ────────────────────────────────────── */
.feedback-section {
  padding: 0 16px 32px;
}

.feedback-trigger {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 8px 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.feedback-panel {
  margin-top: 8px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.feedback-panel.hidden { display: none; }

.feedback-options {
  display: flex;
  flex-direction: column;
}

.feedback-option {
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  text-align: left;
  font-size: 15px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
}

.feedback-option:last-child { border-bottom: none; }
.feedback-option:active, .feedback-option.active { background: var(--orange-light); }

.feedback-message-wrap {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feedback-message-wrap.hidden { display: none; }

.feedback-textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  color: var(--text);
  font-family: inherit;
  resize: none;
}

.feedback-send {
  background: var(--orange);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.feedback-confirm-bar {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.feedback-confirm-bar .feedback-send { width: 100%; }

.feedback-confirm-bar.hidden { display: none; }

/* ── Popup confirmation ──────────────────────────── */
.feedback-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.feedback-popup-overlay.show { opacity: 1; }

.feedback-popup {
  background: var(--card);
  border-radius: 20px;
  padding: 32px 24px 24px;
  width: min(320px, 90vw);
  text-align: center;
  transform: scale(0.85);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.feedback-popup-overlay.show .feedback-popup { transform: scale(1); }

.feedback-popup-icon { font-size: 48px; margin-bottom: 12px; }
.feedback-popup-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.feedback-popup-msg { font-size: 15px; color: var(--text-secondary); margin-bottom: 24px; }

.feedback-popup-btn {
  background: var(--orange);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 14px 48px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

/* ── Météo ───────────────────────────────────────── */
.cloudy-banner {
  background: #F2F2F7;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

@media (prefers-color-scheme: dark) {
  .cloudy-banner { background: #2C2C2E; }
}

/* ── État vide ───────────────────────────────────── */
.empty-state {
  text-align: center;
  color: var(--text-secondary);
  font-size: 15px;
  padding: 48px 16px;
}


/* ── Marqueur position utilisateur ──────────────── */
.user-marker {
  width: 20px; height: 20px;
  background: #007AFF;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,122,255,0.5);
  position: relative;
}

.user-marker::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: rgba(0,122,255,0.15);
  animation: pulse-user 2s ease-out infinite;
}

@keyframes pulse-user {
  0%   { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(2);   opacity: 0; }
}

/* ── Météo vent & UV ─────────────────────────────── */
.weather-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.weather-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
}

.weather-label {
  color: var(--text-secondary);
  font-size: 13px;
  width: 36px;
  flex-shrink: 0;
}

.weather-val { color: var(--text); }

.shelter-tag { font-weight: 500; }

.shelter-info {
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
}
.shelter-yes { background: rgba(0,122,255,0.1); color: #007AFF; }
.shelter-no  { background: rgba(142,142,147,0.15); color: var(--text-secondary); }

/* ── Bannière UV liste ───────────────────────────── */
.uv-banner {
  margin: 0 16px 0;
  padding: 10px 14px;
  background: var(--card);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.uv-banner strong { color: var(--text); }

/* ── Timeline UV fiche ───────────────────────────── */
.uv-timeline {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 72px;
  padding: 0 0 20px;
  position: relative;
  margin-top: 8px;
}

.uv-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  position: relative;
}

.uv-cell-val {
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 3px;
  min-height: 13px;
}

.uv-cell-bar {
  width: 100%;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.3s;
}

.uv-cell-hour {
  position: absolute;
  bottom: 0;
  font-size: 9px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ── Badge UV liste ──────────────────────────────── */
.uv-pill {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 10px;
  white-space: nowrap;
}

/* ── Bannière installation PWA ───────────────────────── */
.install-banner {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  left: 16px;
  right: 16px;
  z-index: 999;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  font-size: 14px;
  animation: slideUp 0.3s ease;
}
.install-banner.hidden { display: none; }
.install-banner span { flex: 1; }
.install-btn {
  flex-shrink: 0;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.install-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
