/* ════════════════════════════════════════════════════════
   layout.css — Structure générale, header, sidebar, sheet
   ════════════════════════════════════════════════════════ */

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

/* ── Header ── */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  height: var(--header-height);
  min-height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: var(--z-header);
  position: relative;
  gap: var(--space-sm);
  overflow: hidden; /* empêche le débordement */
}

.btn-install {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 5px var(--space-sm);
  background: var(--orange-dim);
  color: var(--orange);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-install:hover { background: rgba(255, 107, 53, 0.25); }
.btn-install[hidden] { display: none !important; }

/* ── Logo ── */
.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0; /* permet au texte de se tronquer si besoin */
  flex-shrink: 1;
}

.logo-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: var(--radius-md);
  object-fit: contain;
  background: white;
  padding: 3px;
  box-shadow: 0 0 12px rgba(255, 107, 53, 0.3);
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.logo-sub {
  font-size: 10px;
  color: var(--muted);
  font-weight: 300;
  margin-top: -2px;
  white-space: nowrap;
}

/* ── Header right ── */
.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
  min-width: 0;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--green-dim);
  border: 1px solid rgba(0, 214, 127, 0.25);
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  white-space: nowrap;
  flex-shrink: 0;
}

.live-dot {
  width: 6px;
  height: 6px;
  min-width: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-green 1.5s ease-in-out infinite;
}

.refresh-timer {
  font-size: 11px;
  color: var(--muted);
  min-width: 24px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ── Stats bar ── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: var(--stats-height);
  z-index: var(--z-filters);
  position: relative;
}

.stat-item {
  background: var(--surface);
  padding: 6px var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
}

.stat-icon { font-size: 16px; flex-shrink: 0; }

.stat-val {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  transition: all var(--transition-normal);
  white-space: nowrap;
}

.stat-val.updated { animation: countUp 0.4s ease; }

.stat-label {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Filtre bar ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0 var(--space-md);
  height: var(--filters-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  flex-shrink: 0;
  z-index: var(--z-filters);
  position: relative;
  -webkit-overflow-scrolling: touch;
}

.filter-bar::-webkit-scrollbar { display: none; }

.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-head);
  cursor: pointer;
  white-space: nowrap;
  scroll-snap-align: start;
  transition: all var(--transition-fast);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  min-height: 28px;
  flex-shrink: 0;
}

.filter-chip:hover:not(:disabled) {
  border-color: var(--orange);
  color: var(--text);
}

.filter-chip.active {
  background: var(--orange-dim);
  border-color: var(--orange);
  color: var(--orange);
}

.filter-chip:disabled { opacity: 0.35; cursor: default; }

/* ── Layout principal ── */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 0;
}

/* ── Carte ── */
#map {
  flex: 1;
  height: 100%;
  z-index: var(--z-map);
}

/* ── Sidebar desktop ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  z-index: var(--z-sidebar);
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  padding: var(--space-md) var(--space-sm);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 44px;
}

.tab-btn.active { color: var(--orange); border-bottom-color: var(--orange); }
.tab-btn:hover:not(.active) { color: var(--text); }

.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  gap: var(--space-sm);
  flex-direction: column;
  min-height: 0;
}

.tab-content.active { display: flex; }

.bottom-cta {
  padding: var(--space-md);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Bottom Sheet mobile ── */
.bottom-sheet {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 90dvh;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border-top: 1px solid var(--border);
  z-index: var(--z-sheet);
  will-change: transform;
  flex-direction: column;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
}

.sheet-handle-wrap {
  padding: 10px var(--space-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: grab;
  touch-action: none;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
}

.sheet-handle-wrap:active { cursor: grabbing; }

.sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-full);
}

.sheet-peek-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: var(--space-md);
}

.sheet-peek-label {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
  flex: 1;
  min-width: 0;
}

.btn-signaler-peek {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--orange);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 3px 14px rgba(255, 107, 53, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  flex-shrink: 0;
}

.btn-signaler-peek:active {
  transform: scale(0.95);
  box-shadow: 0 1px 6px rgba(255, 107, 53, 0.3);
}

.sheet-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sheet-tab-btn {
  flex: 1;
  padding: var(--space-sm);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  min-height: 44px;
}

.sheet-tab-btn.active {
  color: var(--orange);
  border-bottom-color: var(--orange);
}

.sheet-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  overscroll-behavior: contain;
}

/* ── Responsive mobile ── */
@media (max-width: 768px) {
  .sidebar      { display: none; }
  .bottom-sheet { display: flex; }
  .main         { height: 100%; }

  /* Header : masquer le sous-titre sur très petits écrans */
  .logo-sub { display: none; }

  /* Stats compactes */
  .stat-label { display: none; }
  .stat-val   { font-size: 15px; }
  .stat-item  { padding: 4px 8px; gap: 6px; }
  .stat-icon  { font-size: 14px; }
}

/* ── Très petits écrans (iPhone SE, etc.) ── */
@media (max-width: 375px) {
  .live-badge span:last-child { display: none; } /* masque "EN DIRECT" text, garde juste le dot */
  .refresh-timer { display: none; }
}