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

html, body, #map {
  height: 100%;
  margin: 0;
  padding: 0;
}

.is-hidden { display: none !important; }

/* --- BOUTONS ZOOM VERTICAUX --- */
.bottom-controls {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1001;
}

.zoom-buttons-vertical {
  display: flex;
  flex-direction: column;
  border-radius: 999px;
  overflow: hidden;
  background-color: white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.zoom-buttons-vertical button {
  width: 44px;
  height: 44px;
  border: none;
  background-color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
}

.zoom-buttons-vertical button:hover {
  background-color: #f0f0f0;
}

.leaflet-control-zoom {
  display: none !important;
}

/* --- BOUTON MAP TOGGLE --- */
.map-toggle {
  width: 44px;
  height: 44px;
  border: none;
  background-color: white;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  user-select: none;
  transition: background-color 0.3s ease;
}

.map-toggle:hover {
  background-color: #f0f0f0;
}

.map-style-menu {
  position: absolute;
  bottom: 10px;
  right: 60px;
  background-color: white;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1002;
}

.map-style-menu button {
  background-color: white;
  border: 1px solid #ccc;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.map-style-menu button:hover {
  background-color: #f0f0f0;
}

/* --- MENU DES COUCHES LEAFLET --- */
.leaflet-control-layers {
  position: absolute !important;
  bottom: 70px !important;
  right: 10px !important;
  background-color: white;
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  width: 180px;
  display: none;
  z-index: 1002;
}

.leaflet-control-layers.leaflet-control-layers-expanded {
  display: block;
}

.leaflet-control-layers label {
  display: flex;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
  color: #333;
}

.leaflet-control-layers input[type="radio"] {
  margin-right: 8px;
  accent-color: #007bff;
}

.leaflet-control-layers-separator {
  border-top: 1px solid #ccc;
  margin: 8px 0;
}

/* --- TOP BAR (desktop / base) --- */
.top-bar-left {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 390px;
  background-color: white;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  padding: 0 16px;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1002;
}

.top-bar-logo {
  height: 28px;
  width: 28px;
  object-fit: contain;
}

.top-bar-title {
  font-weight: 600;
  font-size: 16px;
  color: #333;
  white-space: nowrap;
  user-select: none;
}

.top-bar-search {
  border: 1px solid #ccc;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 14px;
  flex: 1;
  min-width: 120px;
  max-width: 180px;
}

/* --- PANNEAU LISTE + FILTRES (BASE = DESKTOP) --- */
.filter-buttons-left {
  position: absolute;
  top: 60px;          /* sous la top-bar */
  left: 10px;
  width: 360px;       /* un peu plus compact */
  height: 400px;      /* ✅ hauteur fixe voulue */
  background-color: #ffffff;
  border-radius: 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  padding: 10px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1002;
  overflow: hidden;   /* ✅ évite que le detail-panel déborde */
}

.filter-btn {
  flex: 0 0 auto;
  padding: 4px 10px;
  background-color: #ffffff;
  border: 1px solid #ddd;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
  text-align: center;
  white-space: nowrap;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.filter-btn.active {
  background-color: #007bff;
  color: #ffffff;
  border-color: #007bff;
}


.filter-btn:hover:not(.active) {
  background-color: #e6f0ff;
}

.filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.merchant-list {
  flex: 1 1 auto;
  overflow-y: auto;
  max-height: none;      /* on enlève la limite fixe de 400px */
  padding-right: 4px;
  margin-top: 4px;
}

.merchant-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 14px;
}

.merchant-cell:hover {
  background-color: #f9f9f9;
}

.merchant-logo {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: contain;
}

.merchant-info {
  display: flex;
  flex-direction: column;
  line-height: 1.4;
}

/* Header sheet caché par défaut (donc sur desktop) */
.sheet-header {
  display: none;
}

/* --- MENU UTILISATEUR --- */
.top-menu {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 1003;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.menu-toggle {
  background-color: #fff;
  border: none;
  border-radius: 999px;
  width: 44px;
  height: 44px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.menu-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 3px 8px rgba(0,0,0,0.25);
}

.menu-toggle:active {
  transform: scale(0.96);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.user-menu {
  position: fixed;
  top: 64px;
  right: 10px;
  min-width: 280px;
  padding: 10px 0;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow: hidden;
  z-index: 1002;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.user-menu.is-hidden {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}
.user-menu:not(.is-hidden) {
  opacity: 1;
  transform: translateY(0);
}

.user-menu::before {
  content: "";
  position: absolute;
  top: -6px; right: 16px;
  width: 10px; height: 10px;
  background: #fff;
  border-left: 1px solid rgba(0,0,0,0.06);
  border-top: 1px solid rgba(0,0,0,0.06);
  transform: rotate(45deg);
  border-radius: 2px 0 0 0;
}

.user-menu-group {
  padding: 6px 6px;
}

.user-menu .section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: #8e8e93;
  padding: 6px 12px 4px;
}

.menu-separator {
  height: 1px;
  background: #eee;
  margin: 8px 12px;
  border-radius: 1px;
}

.user-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 14px;
  margin: 2px 6px;
  border-radius: 10px;
  border-left: 4px solid transparent;
  text-decoration: none;
  color: #1c1c1e;
  font-size: 15px;
  transition: background-color .18s ease, color .18s ease, border-left-color .18s ease, transform .08s ease;
}

.user-menu a:hover {
  background-color: #f2f2f7;
  border-left-color: #007aff;
  color: #007aff;
}

.user-menu a i[data-lucide] {
  width: 18px; height: 18px; color: #8e8e93;
  display:inline-flex; align-items:center; justify-content:center;
}
.user-menu a:hover i[data-lucide] { color:#007aff; }

.user-menu .cashback-info {
  text-align:center;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
  margin-bottom: 4px;
}
.user-menu .cashback-info div:first-child {
  font-weight:600; font-size:14px; color:#007aff;
}
#cashback-amount { font-weight:700; font-size:1.1em; margin-top:4px; }

.user-menu a.logout { color: #ff3b30; }
.user-menu a.logout:hover {
  background: rgba(255,59,48,0.10);
  border-left-color:#ff3b30;
  color:#ff3b30;
}

.user-menu .user-menu-legal a { font-size:14px; min-height:40px; }

.hidden {
  display: none;
}

/* --- DETAIL PANEL (desktop) --- */
.detail-panel {
  position: absolute;         /* ✅ se place AU-DESSUS du panneau, ne prend plus de place dans le flex */
  inset: 0;                   /* occupe entièrement les 400px */
  background: white;
  border-radius: 16px;
  box-shadow: 0 0 8px rgba(0,0,0,0.1);
  padding-bottom: 20px;
  overflow-y: auto;
  display: none;              /* caché par défaut */
  z-index: 1;                 /* au-dessus de la liste */
}

.detail-panel.visible {
  display: block;             /* montré quand tu ajoutes .visible en JS */
}

.detail-header .close-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  background: #eee;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 20px;
  cursor: pointer;
  z-index: 10;
}

.detail-header {
  display: flex;
  align-items: center;
  height: 120px;
  padding: 0 15px;
  background-size: cover;
  background-position: center;
  border-radius: 20px 20px 0 0;
  position: relative; 
  color: white;
  font-weight: 600;
  font-size: 1.5em;
}

.detail-header .logo {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  object-fit: contain;
  margin-right: 15px;
  box-shadow: 0 0 10px rgba(0,0,0,0.7);
  flex-shrink: 0;
  background-color: white;
}

.detail-header .merchant-name {
  flex-grow: 1;
  line-height: 1.1;
}

.detail-cell {
  background: #f8f8f8;
  margin: 12px 15px;
  border-radius: 12px;
  padding: 12px 15px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-cell button.navigate-btn {
  background-color: #007aff;
  border: none;
  color: white;
  padding: 8px 14px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,122,255,0.5);
  transition: background-color 0.3s ease;
}

.detail-cell button.navigate-btn:hover {
  background-color: #005ecb;
}

.promo-cell {
  background: #e3f2fd;
  margin: 8px 15px;
  border-radius: 12px;
  padding: 12px 15px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  font-size: 0.95em;
  color: #0d47a1;
  font-weight: 600;
}

/* ---- Bannière app mobile (structure de base) ---- */
.app-banner {
  display: none;                 /* affichée seulement en mobile et via JS */
}

.app-banner-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* === MOBILE === */
@media (max-width: 768px) {
  html, body, #map {
    height: 100%;
    width: 100%;
    overflow: hidden;
  }

  .top-bar-left {
    position: fixed;
    top: 10px;
    left: 10px;
    right: 70px;
    width: auto;
    height: auto;
    padding: 8px 10px;
    border-radius: 12px;
    flex-wrap: wrap;
    gap: 8px;
    z-index: 1003;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .top-bar-logo {
    height: 24px;
    width: 24px;
  }

  .top-bar-title {
    font-size: 14px;
  }

  .top-bar-search {
    width: 100%;
    max-width: none;
    margin-top: 6px;
    font-size: 14px;
  }

  .top-menu {
    top: 12px;
    right: 12px;
  }

  /* BOTTOM SHEET mobile */
  .filter-buttons-left {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 60vh;
    border-radius: 18px 18px 0 0;
    padding: 4px 10px 10px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1003;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transform: translateY(0);
    transition: transform 0.25s ease;
  }

  .sheet-header {
    display: flex !important;
    align-items: center;
    gap: 8px;
    padding: 6px 4px 4px;
    cursor: pointer;
  }

  .sheet-drag-handle {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: rgba(0,0,0,0.15);
    margin-right: 4px;
  }

  .sheet-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    flex: 1;
  }

  .sheet-arrow {
    border: none;
    background: transparent;
    font-size: 16px;
    transform: rotate(0deg);
    transition: transform 0.2s ease;
  }

  .filter-buttons {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
  }

  .filter-btn {
    flex: 0 0 auto;
    padding: 8px 14px;
    font-size: 14px;
    border-radius: 999px;
  }

  .merchant-list {
    flex: 1 1 auto;
    max-height: none;
    overflow-y: auto;
    padding-right: 4px;
  }

  .merchant-cell {
    padding: 10px 8px;
    font-size: 14px;
  }

  .merchant-logo {
    width: 40px;
    height: 40px;
  }

  .filter-buttons-left.collapsed {
    transform: translateY(calc(100% - 40px));
  }

  .filter-buttons-left.collapsed .sheet-arrow {
    transform: rotate(180deg);
  }

  .bottom-controls {
    bottom: calc(60vh + 16px);
    right: 12px;
  }

  .map-style-menu {
    bottom: calc(60vh + 16px);
    right: 60px;
  }

  .detail-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-height: 80vh;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -6px 18px rgba(0,0,0,0.25);
    transform-origin: bottom;
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
    z-index: 1004;
    background: white;
  }

  .detail-panel.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .detail-header {
    border-radius: 18px 18px 0 0;
    height: 130px;
  }

  .detail-header .close-btn {
    top: 10px;
    right: 10px;
  }

  .detail-panel.visible ~ #merchant-list,
  .detail-panel.visible ~ .merchant-list {
    display: none;
  }
	
  .app-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 8px 10px;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    z-index: 1004;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
  }

  .app-banner-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
  }

  .app-banner-title {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
  }

  .app-banner-subtitle {
    font-size: 12px;
    color: #6b7280;
  }

  .app-banner-btn {
    border: none;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    background: #007aff;
    color: #fff;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .app-banner-close {
    border: none;
    background: transparent;
    font-size: 18px;
    padding: 0 4px;
    cursor: pointer;
    flex-shrink: 0;
  }

  /* on décale légèrement la top-bar quand la bannière est visible */
  .app-banner-visible + #map + .top-bar-left,
  .app-banner-visible + #map .top-bar-left {
    top: 52px;
  }
}

/* Forcer : sur écran large, jamais de header bottom-sheet */
@media (min-width: 769px) {
  .sheet-header {
    display: none !important;
  }
}
