/* Les écrans rendus par le serveur, sur la charte IKONU.
 *
 * LE PROBLÈME. Les premières versions avaient leurs propres couleurs (bleu pour
 * Sites, sarcelle pour Accès), des polices système et des boutons noirs : rien
 * à voir avec Doc, Note ou Talent. Ce fichier ne pose aucune couleur en dur : il
 * s'appuie sur ikonu-tokens.css (copie de la charte), comme les autres outils,
 * pour que le thème sombre suive sans rien réécrire.
 *
 * Il est commun à IKOTOOL Sites et IKOADMIN Accès (copie identique dans les
 * deux dépôts) : mêmes classes, même mise en page.
 *
 * Téléphone d'abord : champs de 44 px en 16 px (sinon iOS zoome), navigation
 * en barre d'onglets en bas de l'écran comme une application, tableaux en
 * fiches, encoches respectées en mode installé.
 */

@font-face { font-family: "Inter"; src: url(/public/fonts/inter.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url(/public/fonts/space-grotesk.woff2) format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url(/public/fonts/jetbrains-mono.woff2) format("woff2"); font-weight: 100 800; font-display: swap; }

body { font-size: 15px; line-height: 1.5; min-height: 100vh; min-height: 100dvh; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 8px; }
p { margin: 8px 0; }
a { color: var(--brand-text); }
code { font-family: var(--ikn-font-mono); font-size: 0.88em; background: var(--surface-sunken); padding: 1px 6px; border-radius: var(--r-sm); overflow-wrap: anywhere; }
ul { padding-left: 20px; }
li { margin: 4px 0; }
.muet { color: var(--text-muted); font-size: 13px; }

/* --- Barre du haut ----------------------------------------------------- */
.barre {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: 8px;
  min-height: var(--topbar-h);
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.marque { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; margin-right: 12px; }
.marque svg { width: 28px; height: 28px; flex: none; }
.marque span { display: flex; flex-direction: column; line-height: 1.1; }
.marque small { font: 500 10px/1 var(--ikn-font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.marque strong { font: 600 17px/1.2 var(--ikn-font-display); letter-spacing: -0.01em; }
.navigation { display: flex; gap: 2px; flex: 1; }
.navigation a {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 11px;
  border-radius: var(--r-md); color: var(--text-secondary); text-decoration: none; white-space: nowrap;
}
.navigation a svg { width: 18px; height: 18px; flex: none; }
.navigation a:hover { background: var(--surface-hover); color: var(--text); }
.navigation a.actif { background: var(--surface-active); color: var(--text); font-weight: 500; }
.barre form { margin: 0 0 0 auto; }
.sortie { display: inline-grid; place-items: center; width: 36px; height: 36px; min-height: 0; padding: 0; border: 0; border-radius: var(--r-md); background: none; color: var(--text-secondary); cursor: pointer; }
.sortie:hover { background: var(--surface-hover); color: var(--text); }
.sortie svg { width: 18px; height: 18px; }

main { max-width: 1100px; margin: 0 auto; padding: 24px max(24px, env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); }
.tete { margin-bottom: 18px; }
.tete p { margin: 4px 0 0; color: var(--text-muted); max-width: 640px; }

/* --- Cartes et messages ------------------------------------------------ */
.carte { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 18px; margin: 0 0 16px; }
.carte > :first-child { margin-top: 0; }
.carte > :last-child { margin-bottom: 0; }
.info, .alerte { padding: 10px 14px; border-radius: var(--r-lg); margin: 0 0 16px; }
.info { background: var(--success-wash); color: var(--success); }
.alerte { background: var(--warning-wash); color: var(--warning); }
.alerte.danger { background: var(--danger-wash); color: var(--danger); }
.badge { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: var(--r-full); background: var(--surface-sunken); color: var(--text-secondary); font-size: 12px; font-weight: 500; }
.secret { font-family: var(--ikn-font-mono); background: var(--surface-sunken); border: 1px dashed var(--border-strong); border-radius: var(--r-lg); padding: 10px 12px; overflow-wrap: anywhere; }

/* --- Champs et boutons ------------------------------------------------- */
input, select, textarea, button { font: inherit; font-size: 15px; }
input, select, textarea {
  color: var(--text); background: var(--surface-raised);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  padding: 8px 11px; min-height: 40px; max-width: 100%; min-width: 0;
}
textarea { resize: vertical; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-line); box-shadow: 0 0 0 3px var(--brand-wash); }
input[type=file] { padding: 5px; color: var(--text-muted); }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 500; color: var(--text); margin-right: 10px; cursor: pointer;
  min-height: 30px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface-hover);
}
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; padding: 0; margin: 2px 0 0; flex: none; accent-color: var(--brand); }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: var(--r-md); cursor: pointer; white-space: nowrap;
  background: var(--brand); border: 1px solid var(--brand); color: var(--brand-on); font-weight: 500;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
button:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }
button:disabled { opacity: 0.5; cursor: default; }
button.leger { background: var(--surface-raised); border-color: var(--border-strong); color: var(--text); }
button.leger:hover:not(:disabled) { background: var(--surface-hover); }
button.petit { min-height: 32px; padding: 0 10px; font-size: 13px; }
button.danger { background: none; border-color: transparent; color: var(--danger); }
button.danger:hover:not(:disabled) { background: var(--danger-wash); border-color: transparent; }
.ligne { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.ligne > input:not([type=checkbox]):not([type=radio]), .ligne > select { flex: 1 1 180px; }
label.choix { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
progress { width: 100%; height: 6px; border: 0; border-radius: 3px; background: var(--surface-sunken); overflow: hidden; accent-color: var(--brand); }
progress::-webkit-progress-bar { background: var(--surface-sunken); }
progress::-webkit-progress-value { background: var(--brand); }
progress::-moz-progress-bar { background: var(--brand); }

/* --- Tableaux ---------------------------------------------------------- */
.tableau { border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 16px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--text-muted); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-sunken); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td form { margin: 0; }
td .ligne { margin: 0; }

/* --- Médias ------------------------------------------------------------ */
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.vignette { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; font-size: 12.5px; }
.vignette img { width: 100%; aspect-ratio: 4/3; object-fit: cover; background: var(--surface-sunken); display: block; }
.vignette div { padding: 8px 10px; color: var(--text-muted); }
.vignette strong { display: block; color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vide { border: 1px dashed var(--border-strong); border-radius: var(--r-xl); padding: 32px; text-align: center; color: var(--text-muted); }

/* --- Connexion --------------------------------------------------------- */
.accueil { min-height: calc(100dvh - 48px); display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; padding: 24px; }
.accueil svg { width: 72px; height: 72px; }
.accueil h1 { font-size: 30px; }
.accueil p { color: var(--text-muted); max-width: 340px; }
.accueil a.bouton { display: inline-flex; align-items: center; min-height: 44px; padding: 0 20px; border-radius: var(--r-md); background: var(--brand); color: var(--brand-on); text-decoration: none; font-weight: 500; margin-top: 8px; }

/* --- Téléphone --------------------------------------------------------- */
@media (max-width: 720px) {
  body { font-size: 16px; }
  input, select, textarea, button { font-size: 16px; min-height: 44px; }
  button.petit { min-height: 38px; font-size: 14px; }
  main { padding: 16px max(16px, env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  h1 { font-size: 22px; }
  .marque { margin-right: 0; }
  /* Un flou d'arrière-plan fait de la barre le repère des éléments fixés :
     la barre d'onglets resterait collée en haut. Fond plein sur téléphone. */
  .barre { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }

  /* La navigation devient une barre d'onglets fixée en bas, à portée de pouce. */
  .navigation {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sticky);
    gap: 0; justify-content: space-around;
    padding: 6px max(4px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
  }
  .navigation a { flex: 1; flex-direction: column; justify-content: center; gap: 2px; height: 52px; padding: 0 2px; font-size: 11px; border-radius: var(--r-lg); min-width: 0; }
  .navigation a svg { width: 22px; height: 22px; }
  .navigation a.actif { background: none; color: var(--brand-text); }

  .ligne > * { flex: 1 1 100%; }
  .ligne > label.choix { flex-basis: 100%; }
  .tableau { border: 0; background: none; border-radius: 0; overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); margin-bottom: 10px; padding: 8px 14px; }
  td { border: 0; padding: 5px 0; }
  /* L'étiquette est posée à gauche, le contenu de la cellule s'écoule
     normalement à côté (lien, badges, formulaire), quel qu'il soit. */
  td[data-l] { position: relative; padding-left: 100px; min-height: 30px; overflow-wrap: anywhere; }
  td[data-l]::before { content: attr(data-l); position: absolute; left: 0; top: 9px; width: 92px; font: 500 10.5px/1.4 var(--ikn-font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); }
  td[data-l] .badge { margin: 2px 4px 2px 0; }
  td:empty { display: none; }
  .grille { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}
@media (min-width: 721px) {
  form[method=get].ligne > select { flex: 0 1 320px; }
}
