/* ============================================================================
 * assets/app-shell.css — Socle « application » partagé (refonte 2026-07)
 * ----------------------------------------------------------------------------
 * Chargé par TOUTES les pages. Contient :
 *  - la tab bar basse mobile + panneau « Plus » (rendus par app-shell.js)
 *  - le FAB contextuel, les toasts, bottom sheets, skeletons
 *  - l'indicateur hors-ligne / file d'attente
 *  - la suppression des artefacts web sur mobile (tap highlight, zoom…)
 *  - les safe-areas iOS/Android (encoche, barre home)
 * Breakpoint app : < 900 px (aligné sur les media queries existantes).
 * ========================================================================== */

/* ── Artefacts web : neutralisés sur les éléments d'interface ─────────── */
.tabbar, .tabbar *, .app-fab, .app-sheet, .app-toast, .topbar, .nav-overlay,
button, .btn, .btn-primary, .btn-secondary, [role="button"] {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
.tabbar, .app-fab, .topbar-nav a, .nav-overlay a {
  user-select: none;
  -webkit-user-select: none;
}
@media (max-width: 899px) {
  html { overscroll-behavior-y: none; }
  input, select, textarea { font-size: 16px !important; } /* évite le zoom auto iOS */
}

/* ── Tab bar basse (mobile uniquement) ────────────────────────────────── */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 900;
  display: none;
  background: color-mix(in srgb, var(--bg-panel, #141720) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border, #2a3045);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar-inner {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  height: 58px;
}
.tabbar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 44px;
  color: var(--text-secondary, #7a8499);
  text-decoration: none;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  position: relative;
  transition: color 0.15s;
  background: none;
  border: none;
  cursor: pointer;
}
.tabbar-item svg { width: 22px; height: 22px; flex-shrink: 0; }
.tabbar-item.active { color: var(--accent-green, #00e5a0); }
.tabbar-item:active { transform: scale(0.94); transition: transform 0.06s; }
.tabbar-badge {
  position: absolute;
  top: 5px; right: calc(50% - 20px);
  min-width: 15px; height: 15px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent-red, #e84040);
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.58rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 6px rgba(232,64,64,0.6);
}

@media (max-width: 899px) {
  .tabbar { display: block; }
  body { padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 8px); }
  /* La tab bar remplace le burger + l'overlay + la nav horizontale du topbar */
  .burger-btn, .nav-overlay { display: none !important; }
  .topbar-nav { display: none !important; }
  /* Le bouton Paramètres du topbar est déplacé dans le panneau « Plus » */
  #btn-settings { display: none !important; }
  body.nav-bottom { padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 8px); }
  body.nav-bottom .topbar { position: sticky; top: 0; bottom: auto; border-top: none; border-bottom: 1px solid var(--border); }
  /* Safe area haut (encoche) sur la topbar sticky */
  .topbar { padding-top: env(safe-area-inset-top, 0px); height: calc(56px + env(safe-area-inset-top, 0px)); }
}

/* ── Panneau « Plus » + bottom sheets génériques ──────────────────────── */
.app-sheet-backdrop {
  position: fixed; inset: 0;
  z-index: 950;
  background: rgba(8, 10, 14, 0.6);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.2s;
}
.app-sheet-backdrop.open { opacity: 1; }
.app-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 960;
  background: var(--bg-panel, #141720);
  border: 1px solid var(--border, #2a3045);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  padding: 0.5rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
  max-height: 82vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.24s cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
}
.app-sheet.open { transform: translateY(0); }
.app-sheet-grip {
  width: 38px; height: 4px;
  border-radius: 2px;
  background: var(--border, #2a3045);
  margin: 0.35rem auto 0.8rem;
}
.app-sheet-title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-secondary, #7a8499);
  margin-bottom: 0.7rem;
}
.app-sheet-item {
  display: flex; align-items: center; gap: 0.8rem;
  width: 100%;
  padding: 0.8rem 0.6rem;
  min-height: 48px;
  border: none; background: none;
  border-bottom: 1px solid color-mix(in srgb, var(--border, #2a3045) 55%, transparent);
  color: var(--text-primary, #e8ecf0);
  font-family: 'Rajdhani', sans-serif;
  font-size: 1.02rem; font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.12s;
}
.app-sheet-item:last-child { border-bottom: none; }
.app-sheet-item:active { background: var(--bg-hover, #1c2130); }
.app-sheet-item svg { width: 20px; height: 20px; color: var(--accent-green, #00e5a0); flex-shrink: 0; }
.app-sheet-item .app-sheet-item-sub {
  display: block; font-size: 0.72rem; font-weight: 500;
  color: var(--text-secondary, #7a8499);
}

/* ── FAB contextuel ───────────────────────────────────────────────────── */
.app-fab {
  position: fixed;
  right: calc(1rem + env(safe-area-inset-right, 0px));
  bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 16px);
  z-index: 920;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent-green, #00e5a0);
  color: var(--bg-base, #0d0f12);
  font-size: 1.7rem;
  font-weight: 400;
  line-height: 1;
  display: none;
  align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45), 0 0 18px rgba(0, 229, 160, 0.25);
  cursor: pointer;
  transition: transform 0.12s;
}
.app-fab:active { transform: scale(0.9); }
@media (max-width: 899px) { .app-fab.enabled { display: flex; } }

/* ── Toasts / snackbars ───────────────────────────────────────────────── */
.app-toast-wrap {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 14px);
  z-index: 990;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(92vw, 420px);
}
@media (min-width: 900px) { .app-toast-wrap { bottom: 24px; } }
.app-toast {
  background: var(--bg-panel, #141720);
  color: var(--text-primary, #e8ecf0);
  border: 1px solid var(--border, #2a3045);
  border-left: 3px solid var(--accent-green, #00e5a0);
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.92rem; font-weight: 600;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  width: 100%;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.18s, transform 0.18s;
}
.app-toast.show { opacity: 1; transform: translateY(0); }
.app-toast.warning { border-left-color: var(--accent-amber, #f5a623); }
.app-toast.error   { border-left-color: var(--accent-red, #e84040); }

/* ── Indicateur hors-ligne / file d'attente ───────────────────────────── */
.app-offline-bar {
  position: fixed;
  left: 0; right: 0;
  top: 0;
  z-index: 980;
  padding: calc(4px + env(safe-area-inset-top, 0px)) 12px 4px;
  text-align: center;
  background: var(--accent-amber, #f5a623);
  color: #0d0f12;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.06em;
  transform: translateY(-110%);
  transition: transform 0.25s;
}
.app-offline-bar.visible { transform: translateY(0); }
.app-offline-bar.syncing { background: var(--accent-blue, #3d8bff); color: #fff; }

/* ── Skeleton loaders ─────────────────────────────────────────────────── */
.app-skeleton {
  position: relative;
  overflow: hidden;
  background: var(--bg-hover, #1c2130);
  border-radius: 8px;
  min-height: 14px;
}
.app-skeleton::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
  animation: app-skel 1.3s infinite;
  transform: translateX(-100%);
}
@keyframes app-skel { to { transform: translateX(100%); } }

/* ── Pull-to-refresh ──────────────────────────────────────────────────── */
.app-ptr-indicator {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 70px);
  left: 50%; transform: translate(-50%, -60px) rotate(0deg);
  z-index: 940;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--bg-panel, #141720);
  border: 1px solid var(--border, #2a3045);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-green, #00e5a0);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s;
  pointer-events: none;
}
.app-ptr-indicator.spin svg { animation: app-ptr-spin 0.8s linear infinite; }
@keyframes app-ptr-spin { to { transform: rotate(360deg); } }

/* ── Confort tactile générique < 900 px ───────────────────────────────── */
@media (max-width: 899px) {
  .btn-primary, .btn-secondary, .btn, .month-btn, .year-btn, .filter-btn,
  .tab-btn, .subnav-btn { min-height: 44px; }
  table { font-size: 0.85rem; }
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .main-wrapper { padding-left: max(0.75rem, env(safe-area-inset-left)); padding-right: max(0.75rem, env(safe-area-inset-right)); }
}

/* ── Mode standalone (PWA installée / Capacitor) ──────────────────────── */
@media (display-mode: standalone) {
  body { -webkit-user-select: none; user-select: none; }
  input, textarea, [contenteditable], td, pre, code { -webkit-user-select: text; user-select: text; }
}

/* ── Pied de page légal (rendu par app-shell.js sur toutes les pages) ──── */
.app-legal-footer {
  text-align: center;
  padding: 1.6rem 1rem;
  border-top: 1px solid var(--border, #2a3045);
  margin-top: 2.5rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-secondary, #7a8499);
  letter-spacing: 0.04em;
}
.app-legal-footer a,
.app-legal-links a {
  color: var(--text-secondary, #7a8499);
  text-decoration: none;
  margin: 0 0.4rem;
  transition: color 0.15s;
}
.app-legal-footer a:hover,
.app-legal-links a:hover { color: var(--accent-green, #00e5a0); }
.app-legal-footer .alf-sep,
.app-legal-links .alf-sep { opacity: 0.45; }
/* Sur mobile, le footer reste au-dessus de la tab bar grâce au padding-bottom du body */
@media (max-width: 899px) {
  .app-legal-footer { margin-top: 1.6rem; }
}
