/* ============================================================
   BakeryOS — couche mobile (téléphone d'abord)
   Tiroir hors-écran · barre du bas · zones tactiles · encoches iOS
   Chargée APRÈS app.css → surcharge les règles responsives de base.
   ============================================================ */

/* — Éléments réservés au mobile : masqués sur grand écran — */
.hamburger, .drawer-close, .bottomnav, .backdrop, .drawer-controls { display: none; }
.topbar-controls { display: flex; align-items: center; gap: 8px; }
.tbl-wrap { -webkit-overflow-scrolling: touch; }

/* ====================== ≤ 920px : mode téléphone/tablette ====================== */
@media (max-width: 920px) {
  .app { display: block; }
  .main { overflow-x: hidden; }
  .icon-btn { width: 40px; height: 40px; }
  .page { max-width: 100%; }

  /* — Barre supérieure compacte — */
  .topbar { padding: calc(9px + env(safe-area-inset-top)) 12px 9px; gap: 9px; }
  .topbar .crumb { font-size: 16px; }
  .topbar .crumb small { font-size: 11px; }
  .topbar-controls { display: none; }
  .hamburger { display: grid; }

  /* — Sidebar → tiroir hors-écran — */
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; height: 100dvh;
    width: 286px; max-width: 84vw; display: block; flex-wrap: nowrap;
    padding: calc(16px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
    overflow-y: auto; z-index: 60;
    transform: translateX(-100%); transition: transform .28s cubic-bezier(.4, 0, .2, 1);
  }
  .app.drawer-open .sidebar { transform: none; box-shadow: 10px 0 50px rgba(0, 0, 0, .45); }
  .sidebar .nav { display: block; }
  .sidebar .nav a { padding: 12px 12px; font-size: 15px; }
  .brand { padding-bottom: 16px; }
  .drawer-close { display: grid; margin-left: auto; background: rgba(255, 255, 255, .12); border-color: transparent; color: #f7ecd7; }

  /* contrôles dans le tiroir */
  .drawer-controls {
    display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px;
    padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .12);
  }
  .drawer-controls .btn { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .18); color: #f7ecd7; }
  .drawer-controls .btn.primaire { color: #fff; }
  .drawer-controls .lang-seg { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .22); }
  .drawer-controls .lang-seg button { color: #f7ecd7; }
  .drawer-controls .lang-seg button.actif { color: var(--croute-fonce); }

  /* — Voile — */
  .backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(20, 10, 0, .5);
    opacity: 0; visibility: hidden; transition: opacity .28s; }
  .app.drawer-open .backdrop { opacity: 1; visibility: visible; }

  /* — Barre de navigation du bas — (compacte : ~54px + encoche; cible tactile ≥ 44pt Apple) */
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    justify-content: space-around; gap: 2px;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px) saturate(1.2); border-top: 1px solid var(--ligne);
  }
  .bottomnav a, .bottomnav .more {
    flex: 1; min-width: 0; border: 0; background: transparent; cursor: pointer; text-decoration: none;
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 3px 2px;
    color: var(--txt-2); font: inherit; font-size: 10px; font-weight: 600;
  }
  .bottomnav .bic { width: 44px; height: 25px; border-radius: 12px; display: grid; place-items: center; transition: background .18s; }
  .bottomnav .bic svg { width: 20px; height: 20px; }
  .bottomnav a.actif { color: var(--croute); }
  .bottomnav a.actif .bic { background: color-mix(in srgb, var(--ble) 26%, transparent); }
  :root[data-theme="nuit"] .bottomnav a.actif { color: var(--ble); }

  /* dégager le contenu au-dessus de la barre du bas */
  #view { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

  /* — Zones tactiles plus grandes — */
  .cell-input { padding: 9px 8px; min-height: 38px; }
  thead th, tbody td { padding: 11px 12px; }
  .btn { padding: 9px 13px; }
  .seg button { padding: 8px 15px; }

  /* — Hero & KPI ajustés — */
  .hero { padding: 24px 20px; border-radius: 18px; }
  .hero h1.title { font-size: 30px; }
  .hero .inner { gap: 18px; }
  .hero .ring-wrap { margin-left: 0; }
  .hero .chips { gap: 6px; }
  .kpi .value { font-size: 26px; }
}

/* ====================== ≤ 560px : petits téléphones ====================== */
@media (max-width: 560px) {
  .hero h1.title { font-size: 26px; }
  .hero .ring-wrap { margin: 2px auto 0; }
  .hero .ring { margin: 0 auto; }
  .page { padding: 16px 14px 0; }
  .card > .h { font-size: 15.5px; padding: 13px 15px; }
  .card .body { padding: 14px 15px; }
  .bottomnav .blab { font-size: 10px; }
}

/* ====================== ≤ 640px : tableau « Carte & prix » en cartes ====================== */
@media (max-width: 640px) {
  .tbl-cards table, .tbl-cards tbody, .tbl-cards tr, .tbl-cards td, .tbl-cards tfoot { display: block; width: 100%; }
  .tbl-cards thead { display: none; }
  .tbl-cards tbody tr {
    border: 1px solid var(--ligne); border-radius: 13px; margin: 0 0 12px;
    background: var(--surface); box-shadow: var(--ombre-1); overflow: hidden;
  }
  .tbl-cards tbody tr:hover { background: var(--surface); }
  .tbl-cards td {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 14px; border-bottom: 1px solid var(--ligne); text-align: right;
  }
  .tbl-cards td:last-child { border-bottom: 0; }
  .tbl-cards td::before {
    content: attr(data-label); color: var(--txt-2); font-size: 11.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .4px; text-align: left; flex: 0 0 auto;
  }
  .tbl-cards td.prod-name { background: var(--surface-2); justify-content: flex-start; padding: 12px 14px; }
  .tbl-cards td.prod-name::before { content: none; }
  .tbl-cards td.prod-name b { font-family: var(--serif); font-size: 16.5px; }
  .tbl-cards td.marge-cell { background: var(--surface-2); }
  .tbl-cards { overflow: visible; }
  .tbl-cards table, .tbl-cards tbody tr, .tbl-cards td { box-sizing: border-box; max-width: 100%; min-width: 0; }
  .tbl-cards td .cell-input { width: auto; flex: 0 1 130px; min-width: 0; min-height: 40px; border: 1px solid var(--ligne-fort); }
  .tbl-cards tfoot tr {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 4px; padding: 13px 16px; border-radius: 13px;
    background: linear-gradient(120deg, var(--croute-fonce), var(--croute)); color: #fff;
  }
  .tbl-cards tfoot td { display: inline; width: auto; border: 0; padding: 0; background: none; color: inherit; text-align: left; }
  .tbl-cards tfoot td::before { content: none; }
}
