/* ==========================================================================
   TAMAD Lunch — Espace admin
   ========================================================================== */

/* ---------- Connexion ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(900px 500px at 85% -10%, var(--brand-soft), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 40px 36px 32px; box-shadow: var(--shadow-md); text-align: center; }
.login-card img.brand { width: 210px; margin: 0 auto 8px; }
.login-card h1 { font-size: 30px; margin: 8px 0 4px; }
.login-card form { text-align: left; margin-top: 26px; }
.sim-banner { margin-top: 22px; text-align: left; }

/* ---------- Structure ---------- */
.admin { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 26px 18px 20px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar .brand-wrap { padding: 0 8px 22px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.sidebar img.brand { width: 140px; }
.sidebar .brand-sub { margin-top: 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 14.5px; transition: background .15s, color .15s; }
.nav a:hover { background: #f3f4ee; }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav .count { margin-left: auto; font-size: 12px; font-weight: 600; background: var(--brand); color: #fff; border-radius: var(--r-pill); padding: 1px 8px; }
.sidebar .foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.proto-tag { font-size: 11px; color: var(--muted); padding: 0 8px; }

.main { min-width: 0; }
.context-bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 36px; background: rgba(250, 250, 247, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.context-bar .select { width: auto; max-width: 340px; min-height: 38px; padding-top: 7px; padding-bottom: 7px; font-weight: 600; }
.context-bar label { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.context-bar .ctx { display: flex; align-items: center; gap: 10px; }
.page { padding: 34px 36px 80px; max-width: 1240px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head p { color: var(--muted); margin-top: 6px; max-width: 60ch; }
.section-title { font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 34px 0 12px; }

/* ---------- Dashboard ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; }
.hero-main { padding: 32px 34px; }
.hero-main h1 { font-size: 40px; margin: 8px 0 6px; }
.hero-meta { display: grid; grid-template-columns: repeat(3, minmax(0, auto)); gap: 22px; margin-top: 24px; align-items: start; }
.meta-k { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.meta-v { font-weight: 600; display: flex; align-items: center; gap: 10px; line-height: 1.3; }
.hero-stats { background: #fbfcf7; border-left: 1px solid var(--line); padding: 28px 30px; display: flex; flex-direction: column; gap: 18px; justify-content: center; }
.big-stat { display: flex; align-items: baseline; gap: 12px; }
.big-stat .n { font-family: var(--font-display); font-size: 68px; font-weight: 600; line-height: .9; color: var(--brand); font-variant-numeric: tabular-nums; }
.big-stat .l { font-weight: 600; color: var(--ink-2); }
.progress { height: 6px; background: #e8eadf; border-radius: 6px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand-bright); border-radius: 6px; transition: width .5s var(--ease); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 18px; }
.stat .n { font-family: var(--font-display); font-size: 38px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 13px; color: var(--muted); margin-top: 6px; font-weight: 500; }
.stat.warn { background: var(--warn-bg); border-color: var(--warn-line); } .stat.warn .n { color: var(--warn); }
.bar-list { display: flex; flex-direction: column; gap: 14px; }
.bar-item .top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.bar-item .top b { font-variant-numeric: tabular-nums; }

/* ---------- Formation / jours ---------- */
.day-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.day-tab { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; cursor: pointer; font-family: inherit; color: inherit; transition: border-color .15s, box-shadow .15s; }
.day-tab:hover { border-color: var(--ink-2); }
.day-tab[aria-pressed="true"] { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); background: #fbfdf6; }
.day-tab .d { font-family: var(--font-display); font-size: 24px; font-weight: 600; line-height: 1.1; }
.day-tab .sub { font-size: 13px; color: var(--muted); margin: 2px 0 10px; }
.lunch-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.preview-box { background: #fbfcf7; border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px; }
.preview-box h3 { margin: 4px 0 10px; font-family: var(--font-display); font-size: 24px; }
.menu-preview-cat + .menu-preview-cat { margin-top: 16px; }
.menu-preview-cat .cat-name { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--brand); margin-bottom: 6px; }
.menu-preview-cat ul { margin: 0; padding: 0; list-style: none; }
.menu-preview-cat li { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.menu-preview-cat li:last-child { border-bottom: 0; }
.menu-preview-cat li small { display: block; color: var(--muted); font-size: 12.5px; }
.menu-preview-cat li.off { color: var(--muted); text-decoration: line-through; }
.active-banner { display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-radius: var(--r-md); background: var(--brand-soft); border: 1px solid var(--brand-line); animation: rise .35s var(--ease); }
.active-banner .tick { width: 42px; height: 42px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; }
.active-banner .tick .icon { width: 22px; height: 22px; stroke-width: 2.4; }
.active-banner strong { display: block; letter-spacing: .08em; text-transform: uppercase; font-size: 14px; color: var(--brand-hover); }

/* ---------- Menus ---------- */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.menu-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; transition: box-shadow .2s var(--ease), border-color .2s; }
.menu-card:hover { box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.menu-card.archived { opacity: .7; }
.menu-card-head { padding: 18px 20px 14px; display: flex; gap: 14px; align-items: center; border-bottom: 1px solid var(--line); background: #fcfcfa; }
.menu-card-head .nm { font-family: var(--font-display); font-size: 23px; font-weight: 600; line-height: 1.15; }
.menu-card-body { padding: 16px 20px; flex: 1; }
.menu-card-foot { padding: 14px 16px 16px; display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.menu-card-foot .btn.primary-ish { order: -1; flex-basis: 100%; margin-bottom: 6px; }
.menu-card-foot .grow-sp { flex: 1; }
.table td:first-child { min-width: 150px; }

/* ---------- Menu builder ---------- */
.builder-cat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 18px; overflow: hidden; }
.builder-cat-head { display: grid; grid-template-columns: minmax(0, 1fr) 260px auto; gap: 12px; align-items: end; padding: 16px 18px; background: #fbfcf7; border-bottom: 1px solid var(--line); }
.builder-items { padding: 6px 18px 18px; }
.builder-item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.builder-item:last-of-type { border-bottom: 0; }
.builder-item .reorder { display: flex; gap: 2px; }
.builder-add { margin-top: 10px; }

/* ---------- Commandes ---------- */
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .search { position: relative; flex: 1 1 260px; max-width: 380px; }
.filters .search .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.filters .search .input { padding-left: 40px; }
.filters .select { width: auto; min-width: 190px; }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 12.5px; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
.sum-row { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.sum-row:last-child { border-bottom: 0; }
.sum-row b { font-family: var(--font-display); font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; }
.sum-row.zero { color: var(--muted); } .sum-row.zero b { color: var(--muted); font-weight: 500; }
details.dietary summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; }
details.dietary summary::-webkit-details-marker { display: none; }
details.dietary summary::after { content: "Afficher"; font-size: 12.5px; color: var(--brand); font-weight: 600; }
details.dietary[open] summary::after { content: "Masquer"; }
.diet-line { padding: 10px 0; border-top: 1px solid var(--line); }

/* ---------- QR ---------- */
.qr-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 460px); gap: 36px; align-items: start; }
.qr-stage { background: linear-gradient(180deg, #eef1e6, #e6eadb); border-radius: 22px; padding: 34px; display: flex; justify-content: center; }
.qr-card-preview { width: 100%; max-width: 380px; aspect-ratio: 1240 / 1754; box-shadow: 0 24px 60px rgba(40, 55, 20, .22), 0 2px 6px rgba(40, 55, 20, .1); border-radius: 6px; overflow: hidden; background: #fafaf7; }
.qr-card-preview svg { display: block; width: 100%; height: 100%; }
.url-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: #f3f4ee; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; word-break: break-all; color: var(--ink-2); }
.action-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action-list .btn { justify-content: flex-start; }
.print-only { display: none; }

/* ---------- Divers ---------- */
.logo-upload { display: flex; align-items: center; gap: 16px; }
.settings-block + .settings-block { margin-top: 18px; }
.kbd { font-family: ui-monospace, Menlo, monospace; background: #f0f1ea; border: 1px solid var(--line-strong); border-radius: 6px; padding: 1px 7px; font-size: 13px; }
.mobile-menu-btn { display: none; }

/* ---------- Tableaux empilés sur tablette / mobile ---------- */
@media (max-width: 1100px) {
  .table-wrap { border: 0; background: none; overflow: visible; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive thead { display: none; }
  .table.responsive tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 16px; margin-bottom: 10px; }
  .table.responsive td { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; padding: 5px 0; border: 0; }
  .table.responsive td::before { content: attr(data-label); flex: 0 0 120px; padding-top: 3px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .table.responsive td > * { text-align: right; }
  .table.responsive td.actions { justify-content: flex-end; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 10px; }
  .table.responsive td.actions::before { display: none; }
  .table.responsive td:first-child { min-width: 0; }
  .table.responsive tbody tr:hover { background: var(--surface); }
}
.active-banner { flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .hero { grid-template-columns: 1fr; } .hero-stats { border-left: 0; border-top: 1px solid var(--line); }
  .lunch-grid, .qr-layout { grid-template-columns: 1fr; }
  .qr-layout .qr-stage { order: -1; }
}
@media (max-width: 900px) {
  .admin { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 10px 14px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar .brand-wrap { padding: 0 10px 0 0; border: 0; margin: 0; flex: none; } .sidebar img.brand { width: 82px; } .sidebar .brand-sub { display: none; }
  .nav { flex-direction: row; gap: 2px; } .nav a { padding: 9px 12px; white-space: nowrap; font-size: 14px; } .nav a .nav-label { display: inline; }
  .sidebar .foot { margin: 0 0 0 auto; padding: 0; border: 0; flex-direction: row; flex: none; } .proto-tag { display: none; }
  .context-bar { padding: 10px 16px; position: static; gap: 10px 16px; }
  .context-bar .ctx { width: 100%; flex-wrap: wrap; }
  .context-bar .select { flex: 1 1 200px; min-width: 0; max-width: none; width: 100%; } .page { padding: 24px 16px 80px; }
  .hero-main { padding: 24px 20px; } .hero-main h1 { font-size: 32px; } .hero-meta { grid-template-columns: 1fr 1fr; } .hero-stats { padding: 22px 20px; }
  .builder-cat-head { grid-template-columns: 1fr; }
  .builder-item { grid-template-columns: 1fr auto; } .builder-item .desc { grid-column: 1 / -1; order: 3; }
  .login-card { padding: 32px 22px 24px; }
}
@media (max-width: 560px) { .hero-meta { grid-template-columns: 1fr; } .action-list { grid-template-columns: 1fr; } .qr-stage { padding: 18px; } .nav a .nav-label { display: none; } .nav a { padding: 10px 14px; } .nav .count { display: none; } }

/* ---------- Impression ---------- */
@media print {
  @page { margin: 0; }
  body.printing-qr > *:not(.print-only) { display: none !important; }
  body.printing-qr .print-only { display: block !important; width: 100vw; height: 100vh; }
  body.printing-qr .print-only svg { width: 100%; height: 100%; display: block; }
  body.printing-summary > *:not(.print-only) { display: none !important; }
  body.printing-summary .print-only { display: block !important; padding: 24mm 18mm; font-size: 13pt; }
  body.printing-summary .print-only h1 { font-size: 26pt; }
  .toasts, .modal-backdrop { display: none !important; }
}
