/* ═══════════════════════════════════════════
   SERIANCE — Layout
   Structure globale, dock, grilles, responsive
═══════════════════════════════════════════ */

/* ── Structure principale ── */
.main {
  margin-left: 0;
  padding-bottom: 96px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  overflow-x: hidden;
}

.content {
  padding: 12px 16px 100px;
  flex: 1;
  min-height: 100vh;
}

/* ── Sections ── */
.section {
  display: none;
  contain: layout style;
}

@keyframes sectionIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Stagger réservé au tout premier affichage de la session (classe "boot-nav" posée
   sur <body> au chargement, retirée une fois par config_state.js) : ne doit jamais
   rejouer aux clics de navigation suivants (plusieurs centaines/jour cumulés). */
body.boot-nav .section.active .chantier-card,
body.boot-nav .section.active .card-grid .card,
body.boot-nav .section.active .mobile-tile,
body.boot-nav .section.active .postit {
  animation: cardIn .38s cubic-bezier(.22,1,.36,1) both;
}

body.boot-nav .section.active .chantier-card:nth-child(1),
body.boot-nav .section.active .card-grid .card:nth-child(1),
body.boot-nav .section.active .mobile-tile:nth-child(1),
body.boot-nav .section.active .postit:nth-child(1) { animation-delay: .04s; }
body.boot-nav .section.active .chantier-card:nth-child(2),
body.boot-nav .section.active .card-grid .card:nth-child(2),
body.boot-nav .section.active .mobile-tile:nth-child(2),
body.boot-nav .section.active .postit:nth-child(2) { animation-delay: .09s; }
body.boot-nav .section.active .chantier-card:nth-child(3),
body.boot-nav .section.active .card-grid .card:nth-child(3),
body.boot-nav .section.active .mobile-tile:nth-child(3),
body.boot-nav .section.active .postit:nth-child(3) { animation-delay: .14s; }
body.boot-nav .section.active .chantier-card:nth-child(4),
body.boot-nav .section.active .card-grid .card:nth-child(4),
body.boot-nav .section.active .mobile-tile:nth-child(4),
body.boot-nav .section.active .postit:nth-child(4) { animation-delay: .19s; }
body.boot-nav .section.active .chantier-card:nth-child(5),
body.boot-nav .section.active .card-grid .card:nth-child(5),
body.boot-nav .section.active .mobile-tile:nth-child(5),
body.boot-nav .section.active .postit:nth-child(5) { animation-delay: .23s; }
body.boot-nav .section.active .chantier-card:nth-child(6),
body.boot-nav .section.active .card-grid .card:nth-child(6),
body.boot-nav .section.active .mobile-tile:nth-child(6),
body.boot-nav .section.active .postit:nth-child(6) { animation-delay: .27s; }
body.boot-nav .section.active .chantier-card:nth-child(n+7),
body.boot-nav .section.active .card-grid .card:nth-child(n+7),
body.boot-nav .section.active .mobile-tile:nth-child(n+7),
body.boot-nav .section.active .postit:nth-child(n+7) { animation-delay: .30s; }

.section.active {
  display: flex;
  flex-direction: column;
  width: 100%;
  contain: none;
}

body.boot-nav .section.active {
  animation: sectionIn .32s cubic-bezier(.22,1,.36,1) both;
}

/* ── Topbar ── */
.nav-section  { display: none; }

/* ── Save flash ── */
#save-flash {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  background: var(--glass-a);
  backdrop-filter: var(--blur-sm);
  -webkit-backdrop-filter: var(--blur-sm);
  border: 1px solid var(--gb-hi);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 12px;
  font-size: .79rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
  box-shadow: var(--sh), var(--hi);
}

#save-flash.show { opacity: 1; }

/* ── Bandeau hors-ligne (mode écriture offline, vague 1) ── */
#offline-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  min-height: 26px;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  padding: 3px 8px;
  background: #b45309;
  color: #fff;
  font-size: .79rem;
  font-weight: 600;
  letter-spacing: .01em;
}
.offline-banner-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: offline-pulse 1.6s ease-in-out infinite;
}
@keyframes offline-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}
#offline-sync-btn {
  border: 1px solid rgba(255,255,255,.55);
  background: rgba(255,255,255,.12);
  color: #fff;
  font: inherit;
  font-weight: 700;
  border-radius: 8px;
  padding: 1px 10px;
  cursor: pointer;
}
#offline-sync-btn:disabled { opacity: .6; cursor: default; }
.offline-banner-discard {
  border: 1px solid rgba(255,255,255,.3);
  background: transparent;
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  border-radius: 8px;
  padding: 1px 8px;
  cursor: pointer;
  opacity: .85;
}
.offline-banner-discard:hover { opacity: 1; }
/* Décale le topbar + le contenu pour laisser la place au bandeau, sans toucher
   aux règles de padding existantes (juste un décalage additif). Hauteur réelle posée en JS
   (--offline-banner-h, offline_queue.js _offlineSyncBannerHeight) : le message peut passer
   sur 2 lignes selon son contenu, 26px (une ligne) sert de repli avant que le JS tourne. */
body.offline-active #user-topbar { top: var(--offline-banner-h, 26px); }
body.offline-active .main { margin-top: var(--offline-banner-h, 26px); }

/* ── Grilles ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }

/* ── Textes de page ── */
.page-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text);
  margin-bottom: 8px;
  padding-left: 14px;
  position: relative;
}

.page-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 1px;
  bottom: 1px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.page-subtitle {
  font-size: .79rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-dim);
  font-size: .85rem;
}

.empty-state .icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

/* ══════════════════════════════
   DOCK macOS
══════════════════════════════ */
#dock {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 14px;
  background: var(--modal-bg);
  border: 1px solid var(--gb);
  border-radius: 12px;
  box-shadow: var(--sh-lg);
  z-index: 400;
  animation: dock-in .5s cubic-bezier(.34,1.4,.64,1) both;
  /* Beaucoup d'icônes (poste avec tous les accès) + fenêtre/tablette étroite (portrait iPad 834px,
     fenêtre desktop redimensionnée) : la barre peut dépasser la largeur de l'écran. Sans ça elle
     débordait des deux côtés sans aucun moyen d'atteindre les icônes hors écran (2026-11-03). */
  max-width: calc(100vw - 24px);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#dock::-webkit-scrollbar { display: none; }

.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  cursor: pointer;
  transform-origin: bottom center;
  isolation: isolate;
  backface-visibility: hidden;
  flex-shrink: 0;
  animation: dock-item-in .4s cubic-bezier(.34,1.4,.64,1) both;
}

.dock-item:active .dock-icon {
  transform: scale(.84);
  transition: transform .08s;
}

.dock-item::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transition: opacity .2s;
}

.dock-item.active::after { opacity: 1; }

.dock-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-h);
  border: 1px solid var(--gb);
  color: var(--text);
  transition:
    width .13s cubic-bezier(.34,1.56,.64,1),
    height .13s cubic-bezier(.34,1.56,.64,1),
    border-radius .13s,
    background .15s,
    box-shadow .15s;
}

.dock-item.active .dock-icon {
  background: var(--accent);
  color: var(--on-accent);
  border-color: transparent;
}

/* Nom accessible de l'onglet (lu par lecteur d'écran), invisible à l'oeil :
   l'infobulle visible est #dock-tooltip (élément unique, position:fixed,
   géré en JS dans dock_perso.js) pour échapper au clip de l'overflow-x
   du dock (défilement horizontal tablette, cf. commit 2026-11-03). */
.dock-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Infobulle partagée du dock (survol/focus clavier), positionnée en JS */
#dock-tooltip {
  position: fixed;
  z-index: 500;
  background: rgba(0,0,0,.8);
  color: #fff;
  font-size: .79rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s;
}
#dock-tooltip::after {
  content: '';
  position: absolute;
  border: 5px solid transparent;
}
/* Orientation par défaut : infobulle au-dessus de l'icône (dock horizontal).
   top JS = haut de l'icône - gap ; translateY(-100%) fait remonter toute
   la bulle au-dessus de ce point au lieu de la faire déborder sur l'icône.
   Pas d'animation de position (seulement un fondu) : distance au logo
   toujours identique, l'ancienne légère glissade donnait une impression
   d'écart qui bouge (2026-11-04). */
#dock-tooltip.dt-top {
  transform: translate(-50%, -100%);
}
#dock-tooltip.dt-top::after {
  top: 100%; left: 50%; transform: translateX(-50%);
  border-top-color: rgba(0,0,0,.8);
}
/* Variante barre latérale verticale : infobulle à droite de l'icône */
#dock-tooltip.dt-right {
  transform: translate(0, -50%);
}
#dock-tooltip.dt-right::after {
  top: 50%; left: -5px; transform: translateY(-50%);
  border-top-color: transparent; border-right-color: rgba(0,0,0,.8);
}
#dock-tooltip.show { opacity: 1; }

.dock-sep {
  width: 1px;
  height: 32px;
  background: rgba(128,128,128,.3);
  margin: 0 2px;
  align-self: center;
}

/* Dock personnalisable : icône tirée, place vide, menu clic droit */
.dock-item.dock-placeholder { opacity: .18; }
.dock-ghost {
  position: fixed;
  z-index: 520;
  margin: 0;
  pointer-events: none;
  animation: none;
  transform: scale(1.18);
  filter: drop-shadow(0 12px 20px rgba(0,0,0,.4));
}
body.dock-grabbing, body.dock-grabbing * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.dock-menu {
  position: fixed;
  z-index: 530;
  min-width: 220px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--modal-bg);
  color: var(--text);
  border: 1px solid var(--gb);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0,0,0,.35);
  animation: dock-menu-in .16s cubic-bezier(.34,1.4,.64,1) both;
}
.dock-menu-item {
  text-align: left;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: .85rem;
  cursor: pointer;
}
.dock-menu-item:hover, .dock-menu-item:focus-visible { background: var(--glass-h); outline: none; }
@keyframes dock-menu-in {
  from { opacity: 0; transform: translateY(8px) scale(.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Animations dock */
@keyframes dock-in {
  from { opacity: 0; transform: translateX(-50%) translateY(24px) scale(.92); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@keyframes dock-item-in {
  from { opacity: 0; transform: translateY(16px) scale(.8); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dock-item:nth-child(1)  { animation-delay: .04s; }
.dock-item:nth-child(2)  { animation-delay: .08s; }
.dock-item:nth-child(3)  { animation-delay: .12s; }
.dock-item:nth-child(4)  { animation-delay: .16s; }
.dock-item:nth-child(5)  { animation-delay: .20s; }
.dock-item:nth-child(6)  { animation-delay: .24s; }
.dock-item:nth-child(7)  { animation-delay: .28s; }
.dock-item:nth-child(8)  { animation-delay: .32s; }

/* ══════════════════════════════
   DOCK — variante barre latérale (toggle via toggleNavStyle())
══════════════════════════════ */
body.nav-sidebar .main { margin-left: 88px; padding-bottom: 24px; }

body.nav-sidebar #dock {
  bottom: auto;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  flex-direction: column;
  align-items: center;
  border-radius: 12px;
  padding: 14px 8px;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  animation: dock-in-side .5s cubic-bezier(.34,1.4,.64,1) both;
}

body.nav-sidebar .dock-sep {
  width: 28px;
  height: 1px;
  margin: 2px 0;
}

@keyframes dock-in-side {
  from { opacity: 0; transform: translateY(-50%) translateX(-24px) scale(.92); }
  to   { opacity: 1; transform: translateY(-50%) translateX(0) scale(1); }
}

@media (max-width: 860px) {
  body.nav-sidebar .main { margin-left: 0; }
  body.nav-sidebar #dock {
    bottom: 14px; top: auto; left: 50%; transform: translateX(-50%);
    flex-direction: row; max-height: none;
    max-width: calc(100vw - 24px); overflow-x: auto; overflow-y: hidden;
  }
  body.nav-sidebar .dock-sep { width: 1px; height: 32px; margin: 0 2px; }
}
.dock-item:nth-child(9)  { animation-delay: .36s; }
.dock-item:nth-child(10) { animation-delay: .40s; }

/* ── FAB tâches ── */
#fab-tache {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  cursor: pointer;
  font-size: 1.6rem;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  transition: transform .2s, box-shadow .2s;
}

@media (hover: hover) and (pointer: fine) {
  #fab-tache:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
  }
}

#fab-tache svg            { transition: transform .3s; }
@media (hover: hover) and (pointer: fine) {
  #fab-tache:hover svg      { transform: rotate(90deg); }
}

.taches-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

/* ══════════════════════════════
   RESPONSIVE
══════════════════════════════ */
@media (max-width: 1100px) {
  :root { --sidebar-w: 0px; }
  .grid-2    { grid-template-columns: repeat(2, 1fr); }
  .card-grid         { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .ch-detail-header  { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .main            { margin-left: 0 !important; padding: 12px; padding-top: 56px; }
  .section         { padding: 14px 10px; }
  .page-title      { font-size: 1.1rem; }
  .grid-2 { grid-template-columns: repeat(3, 1fr); }
  .ch-detail-header { grid-template-columns: 1fr !important; }
  .card-grid       { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
  .chantier-grid   { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .fourn-grid      { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  #calcul-pills    { gap: 7px !important; }
  #fab-tache       { bottom: 16px; right: 16px; width: 48px; height: 48px; }
  #section-calcul [style*="grid-template-columns:280px"] { grid-template-columns: 1fr !important; }
  .taches-toolbar select { min-width: 90px !important; }

  /* Barre haute Planning (zoom + filtres) : overflow-x:auto sans indice visuel
     sur tablette — recherche/filtres/export passaient invisibles hors écran. */
  #section-planning > div:first-child,
  #section-planning-semaine > div:first-child {
    flex-wrap: wrap !important;
    overflow-x: visible !important;
    min-height: 0 !important;
    row-gap: 6px;
  }
}

@media (max-width: 640px) {
  .main        { padding: 8px; }
  .section     { padding: 10px 6px; }
  .card        { padding: 12px; }
  .page-title  { font-size: 1.1rem; }
  .card-grid   { grid-template-columns: 1fr; gap: 8px; }
  .postit      { min-height: 100px; padding: 10px 10px 8px; }
  .taches-toolbar             { gap: 5px !important; }
  .taches-toolbar select      { font-size: .79rem; min-width: 80px !important; }
  .btn-sm      { font-size: .79rem; padding: 5px 8px; }
  .result-box  { padding: 10px; }
  .chantier-grid, .fourn-grid { grid-template-columns: 1fr; }
  #fab-tache   { bottom: 12px; right: 12px; width: 44px; height: 44px; font-size: 1.4rem; }
}

/* ══════════════════════════════
   MODE LÉGER (machines faibles : html.perf-lite posé au démarrage, cf. index.html)
   Supprime les flous (RAM GPU) et les animations infinies décoratives
══════════════════════════════ */
html.perf-lite { --blur: none; --blur-sm: none; }
html.perf-lite *, html.perf-lite *::before, html.perf-lite *::after {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
html.perf-lite .modal-overlay,
html.perf-lite #recherche-overlay { background: rgba(0,0,0,.66); }
html.perf-lite #dock { background: var(--modal-bg); }
html.perf-lite #user-topbar { background: var(--modal-bg) !important; }
html.perf-lite .offline-banner-dot,
html.perf-lite .point.active { animation: none !important; }
