/* ══════════════════════════════════════════════════════════════════════════
   app-shell.css — coquille commune de l'espace connecté (nouvelle transcription,
   lot, workflows, historique, compte).
   Maquette validée par Ruben le 22/09/2026 (maquette/app.css + shell.js), v2
   le 23/09 (outils.css + shell2.js) : barre latérale dès 768 px (216 px de
   768 à 900), barre d'onglets du bas seulement sous 768 px.
   Loi : DESIGN.md §2-5. Les couleurs viennent du :root de la page (tokens
   --primary, --bg, --surface, --border, --text*…) : ce fichier n'en redéfinit
   aucune, il ne fait que les consommer.
   Préfixe dk- partout : history.html et account.html avaient déjà leurs
   propres .shell / .page-head, qu'il ne fallait pas écraser.
   ══════════════════════════════════════════════════════════════════════════ */

.dk-app { background: var(--surface); }
.dk-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

/* ── Barre latérale (≥ 768 px) ─────────────────────────────────────────── */
.dk-side { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 24px; padding: 16px; background: var(--bg); border-inline-end: 1px solid var(--border); }
.dk-logo { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; color: var(--text); text-decoration: none; }
.dk-logo img { width: 28px; height: 28px; flex-shrink: 0; }
.dk-new { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--primary); color: #fff; font-size: 14px; font-weight: 600; line-height: 1.2; text-decoration: none; text-align: center; transition: background var(--transition), box-shadow var(--transition); }
.dk-new:hover { background: var(--primary-hover); box-shadow: var(--shadow-sm); }
.dk-snav { display: grid; gap: 2px; }
.dk-snav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; color: var(--text-muted); text-decoration: none; transition: background var(--transition), color var(--transition); }
.dk-snav a svg { flex-shrink: 0; }
.dk-snav a:hover { background: var(--surface); color: var(--text); }
.dk-snav a[aria-current="page"] { background: var(--primary-50); color: var(--text); font-weight: 600; }
.dk-snav a[aria-current="page"] svg { color: var(--primary); }
.dk-snav .dk-lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dk-snav .dk-cnt { margin-inline-start: auto; font-size: 12px; color: var(--text-light); font-variant-numeric: tabular-nums; }
.dk-slabel { padding: 0 12px; margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--text-light); }

/* Jauges d'usage : valeurs lues sur /auth/me et /auth/usage, jamais écrites ici */
.dk-use { margin-top: auto; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); display: grid; gap: 12px; }
.dk-use[hidden] { display: none; }
.dk-use-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 600; color: var(--text); }
.dk-use-top a { font-size: 13px; font-weight: 500; color: var(--primary); text-decoration: none; min-height: 24px; display: inline-flex; align-items: center; }
.dk-use-top a:hover { text-decoration: underline; }
.dk-urow { display: grid; gap: 4px; font-size: 12px; color: var(--text-muted); }
.dk-urow[hidden] { display: none; }
.dk-urow .dk-l { display: flex; justify-content: space-between; gap: 8px; }
.dk-urow .dk-l b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.dk-gauge { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.dk-gauge i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--primary); }
.dk-gauge i.is-high { background: var(--warn); }
.dk-gauge i.is-full { background: var(--error); }
.dk-use-meta { font-size: 12px; color: var(--text-light); }
/* Identité + déconnexion en bas de la barre (maquette outils.css .me-row) */
.dk-me-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.dk-me-row .dk-me { flex: 1; }
.dk-out { width: 44px; height: 44px; flex-shrink: 0; display: grid; place-items: center; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); cursor: pointer; transition: background var(--transition), color var(--transition); }
.dk-out:hover { background: var(--surface); color: var(--text); }
.dk-out:disabled { opacity: .5; cursor: progress; }
.dk-me { display: flex; align-items: center; gap: 12px; padding: 8px; min-height: 48px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; min-width: 0; }
.dk-me:hover { background: var(--surface); }
.dk-av { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-light); color: var(--primary-hover); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0; overflow: hidden; }
.dk-av img { width: 100%; height: 100%; object-fit: cover; }
.dk-me-txt { min-width: 0; }
.dk-me b { display: block; font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dk-me span.dk-mail { unicode-bidi: plaintext; text-align: start; display: block; font-size: 12px; color: var(--text-light); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dk-guest { margin-top: auto; display: grid; gap: 8px; }
.dk-guest a { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; text-decoration: none; }
.dk-guest .dk-g1 { background: var(--primary); color: #fff; }
.dk-guest .dk-g2 { border: 1px solid var(--border-2); color: var(--primary); background: var(--bg); }

/* ── Zone principale + en-tête de page ─────────────────────────────────── */
.dk-main { min-width: 0; }
.dk-page-h { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 32px 32px 0; }
.dk-page-h .dk-ph-txt { min-width: 0; flex: 1 1 280px; }
.dk-page-h h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; color: var(--text); }
.dk-page-h p { font-size: 14px; color: var(--text-muted); margin-top: 2px; overflow-wrap: anywhere; }
.dk-page-h .dk-end { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Tablette 768–900 px : barre latérale plus étroite (maquette outils.css) ── */
@media (min-width: 768px) and (max-width: 900px) {
  .dk-shell { grid-template-columns: 216px minmax(0, 1fr); }
  .dk-side { padding: 16px 12px; }
  .dk-page-h { padding: 24px 24px 0; }
}

/* ── Barre d'onglets mobile (≤ 767 px) ─────────────────────────────────── */
.dk-tabbar { display: none; }
@media (max-width: 767px) {
  .dk-shell { grid-template-columns: minmax(0, 1fr); }
  .dk-side { display: none; }
  .dk-page-h { padding: 16px 16px 0; }
  .dk-page-h h1 { font-size: 24px; }
  /* Titre et actions (langue, Accueil) sur la même ligne : 280 px de base renvoyaient les actions seules sur une ligne vide. */
  .dk-page-h .dk-ph-txt { flex-basis: 150px; }
  .dk-page-h .dk-end { align-self: flex-start; }
  .dk-tabbar { position: fixed; inset-inline: 0; bottom: 0; z-index: 900; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); height: calc(64px + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(255,255,255,0.95); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--border); }
  .dk-tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 0; padding: 0 4px; font-size: 11px; font-weight: 600; color: var(--text-light); text-decoration: none; }
  .dk-tabbar a span.dk-tl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dk-tabbar a[aria-current="page"] { color: var(--primary); }
  .dk-tabbar .dk-plus { width: 40px; height: 32px; border-radius: 999px; background: var(--primary); color: #fff; display: grid; place-items: center; }
  /* Les éléments fixés en bas de page remontent au-dessus de la barre d'onglets. */
  .dk-app .ck-banner { bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .dk-app #dokitscriptChat .ds-chat-bubble { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  .dk-app #dokitscriptChat .ds-chat-panel { bottom: calc(148px + env(safe-area-inset-bottom, 0px)); max-height: calc(100vh - 170px); }
}
@media (max-width: 360px) {
  .dk-tabbar a { font-size: 10px; }
}

.dk-shell :focus-visible, .dk-tabbar :focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* Champs de saisie : ils ont leur propre cadre violet au focus ; le contour ci-dessus s'y ajoutait en second rectangle (relevé par Ruben le 23/09). */
.dk-shell input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):focus-visible, .dk-tabbar input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):focus-visible,
.dk-shell textarea:focus-visible, .dk-tabbar textarea:focus-visible,
.dk-shell select:focus-visible, .dk-tabbar select:focus-visible { outline: none; }
.dk-snav a:active, .dk-new:active, .dk-tabbar a:active, .dk-me:active, .dk-out:active { transform: scale(var(--press-scale, .97)); }

/* Bouton « Accueil » en haut à droite (renderHead dans app-shell.js) : sortie vers le site, à côté du sélecteur de langue. */
#headerActions { display: flex; align-items: center; gap: 8px; }
.dk-home { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text-muted); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; transition: background var(--transition, .15s ease), color var(--transition, .15s ease), border-color var(--transition, .15s ease); }
.dk-home:hover { background: var(--surface); color: var(--text); border-color: var(--border-2, var(--border)); }
.dk-home:active { transform: scale(var(--press-scale, .97)); }
@media (max-width: 767px) {
  .dk-home { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .dk-home .dk-lbl { display: none; }
}
