/* ===================================================================
   OrderBot — Design system partagé (Agent B)
   -------------------------------------------------------------------
   Ce fichier est consommé par TOUTES les pages (index, dashboard,
   admin, ticket). Il contient :
     1. L'import de la police Inter (Google Fonts)
     2. Les variables CSS (tokens du §2 du CONTRACT)
     3. Un reset léger + styles de base (body, scrollbars, focus)
     4. Des utilitaires non couverts par Tailwind
     5. Un bloc @media print réutilisable pour le ticket (~80mm)

   Conventions :
     - Couleurs/typos/rayons = tokens du CONTRACT, à NE PAS dupliquer
       en dur ailleurs.
     - Tout est commenté en français.
   =================================================================== */

/* -------------------------------------------------------------------
   1. POLICE — Inter (poids utiles uniquement pour rester léger)
   ------------------------------------------------------------------- */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap");

/* -------------------------------------------------------------------
   2. TOKENS DE DESIGN (cf. §2 du CONTRACT — source de vérité)
   ------------------------------------------------------------------- */
:root {
  /* Couleurs principales */
  --ob-orange: #e85d04;       /* accent : boutons, liens, focus */
  --ob-orange-dark: #c44d00;  /* survol des éléments orange */
  --ob-noir: #1a1a2e;         /* fond sombre, header, texte */
  --ob-noir-soft: #2a2a40;    /* surfaces sombres secondaires */
  --ob-bg: #f7f7fa;           /* fond clair de l'application */
  --ob-text: #1a1a2e;         /* couleur de texte par défaut */

  /* Couleurs dérivées (utilitaires, non normatives) */
  --ob-orange-soft: #fdecdf;  /* fond doux orangé (hints, badges) */
  --ob-text-muted: #5b5b6e;   /* texte secondaire */
  --ob-border: #e4e4ee;       /* bordures claires */
  --ob-danger: #c0392b;       /* messages d'erreur */
  --ob-success: #1f8a52;      /* messages de succès */
  --ob-white: #ffffff;

  /* Rayon de référence */
  --ob-radius: 14px;
  --ob-radius-sm: 10px;
  --ob-radius-lg: 22px;

  /* Ombres (profondeur maîtrisée) */
  --ob-shadow-sm: 0 2px 8px rgba(26, 26, 46, 0.06);
  --ob-shadow: 0 10px 30px rgba(26, 26, 46, 0.10);
  --ob-shadow-lg: 0 24px 60px rgba(26, 26, 46, 0.18);

  /* Typographie */
  --ob-font: "Inter", "Roboto", system-ui, sans-serif;

  /* Animation */
  --ob-duration: 200ms;
  --ob-ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* Cible tactile minimale (boutons) */
  --ob-tap: 52px;
}

/* -------------------------------------------------------------------
   3. RESET LÉGER + BASE
   ------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--ob-font);
  color: var(--ob-text);
  background: var(--ob-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Filet de sécurité : aucune page ne défile horizontalement sur petit écran. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

/* Barre d'onglets/filtres défilante horizontalement (1 seule ligne).
   Utilisée pour les filtres de commandes (réception, cuisine). */
.ob-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
  padding-bottom: 2px;
}
.ob-tabs::-webkit-scrollbar {
  display: none; /* WebKit */
}
.ob-tabs > * {
  flex: 0 0 auto; /* les onglets ne rétrécissent pas : ils défilent */
  white-space: nowrap;
}

/* Les images/médias ne débordent jamais de leur conteneur */
img,
svg,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Les éléments de formulaire héritent de la police */
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

/* Focus visible et cohérent au clavier (accessibilité) */
:focus-visible {
  outline: 3px solid var(--ob-orange);
  outline-offset: 2px;
  border-radius: 4px;
}

/* On masque l'outline au pointeur si le focus-visible est supporté */
:focus:not(:focus-visible) {
  outline: none;
}

/* Scrollbars sobres (WebKit) */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(26, 26, 46, 0.18);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(26, 26, 46, 0.32);
  background-clip: padding-box;
}

/* Scrollbars Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(26, 26, 46, 0.25) transparent;
}

/* -------------------------------------------------------------------
   4. UTILITAIRES (non couverts par Tailwind ou réutilisés partout)
   ------------------------------------------------------------------- */

/* Réservé au lecteur d'écran : visible uniquement par les technologies
   d'assistance (skip-links, libellés invisibles). */
.ob-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Lien d'évitement : caché jusqu'au focus clavier */
.ob-skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 100;
  background: var(--ob-noir);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: var(--ob-radius-sm);
  transition: top var(--ob-duration) var(--ob-ease);
}

.ob-skip-link:focus {
  top: 1rem;
}

/* Dégradé radial d'ambiance pour les fonds sombres (hero, header) */
.ob-aura {
  background-image:
    radial-gradient(60% 90% at 18% 0%, rgba(232, 93, 4, 0.28), transparent 60%),
    radial-gradient(50% 80% at 100% 100%, rgba(232, 93, 4, 0.12), transparent 55%);
}

/* Grain léger optionnel pour donner de la texture aux surfaces sombres */
.ob-grain::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: radial-gradient(rgba(255, 255, 255, 0.7) 0.5px, transparent 0.5px);
  background-size: 4px 4px;
}

/* Carte de surface réutilisable (modale de login, panneaux) */
.ob-surface {
  background: var(--ob-white);
  border: 1px solid var(--ob-border);
  border-radius: var(--ob-radius);
  box-shadow: var(--ob-shadow);
}

/* Champ de saisie standard partagé (login, formulaires admin) */
.ob-input {
  width: 100%;
  min-height: var(--ob-tap);
  padding: 0.75rem 1rem;
  background: var(--ob-bg);
  border: 1.5px solid var(--ob-border);
  border-radius: var(--ob-radius-sm);
  transition: border-color var(--ob-duration) var(--ob-ease),
              box-shadow var(--ob-duration) var(--ob-ease),
              background var(--ob-duration) var(--ob-ease);
}

.ob-input::placeholder {
  color: var(--ob-text-muted);
  opacity: 0.7;
}

.ob-input:hover {
  border-color: #cfcfdf;
}

.ob-input:focus {
  outline: none;
  background: var(--ob-white);
  border-color: var(--ob-orange);
  box-shadow: 0 0 0 4px rgba(232, 93, 4, 0.16);
}

/* Champ en erreur (validation) */
.ob-input.is-error {
  border-color: var(--ob-danger);
  box-shadow: 0 0 0 4px rgba(192, 57, 43, 0.12);
}

/* Bouton principal orange réutilisable */
.ob-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--ob-tap);
  padding: 0 1.5rem;
  border: none;
  border-radius: var(--ob-radius);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--ob-duration) var(--ob-ease),
              background var(--ob-duration) var(--ob-ease),
              box-shadow var(--ob-duration) var(--ob-ease),
              filter var(--ob-duration) var(--ob-ease);
  will-change: transform;
}

.ob-btn:active {
  transform: translateY(1px) scale(0.99);
}

.ob-btn--primary {
  background: var(--ob-orange);
  color: #fff;
  box-shadow: 0 8px 20px rgba(232, 93, 4, 0.32);
}

.ob-btn--primary:hover {
  background: var(--ob-orange-dark);
  box-shadow: 0 12px 26px rgba(232, 93, 4, 0.4);
}

.ob-btn--ghost {
  background: transparent;
  color: var(--ob-text);
  border: 1.5px solid var(--ob-border);
}

.ob-btn--ghost:hover {
  border-color: var(--ob-orange);
  color: var(--ob-orange-dark);
}

.ob-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  filter: grayscale(0.3);
}

/* Bloc message (erreur / succès) injecté par JS */
.ob-message {
  display: none;
  padding: 0.75rem 1rem;
  border-radius: var(--ob-radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
}

.ob-message.is-visible {
  display: block;
}

.ob-message--error {
  background: rgba(192, 57, 43, 0.1);
  color: var(--ob-danger);
  border: 1px solid rgba(192, 57, 43, 0.35);
}

.ob-message--success {
  background: rgba(31, 138, 82, 0.1);
  color: var(--ob-success);
  border: 1px solid rgba(31, 138, 82, 0.35);
}

/* Badge d'indice (rappel des identifiants démo) */
.ob-hint {
  background: var(--ob-orange-soft);
  border: 1px dashed rgba(232, 93, 4, 0.45);
  border-radius: var(--ob-radius-sm);
  padding: 0.7rem 0.9rem;
  font-size: 0.82rem;
  color: var(--ob-orange-dark);
}

.ob-hint code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-weight: 700;
}

/* Animation d'apparition douce (modale, sections au scroll) */
@keyframes ob-fade-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ob-fade-up {
  animation: ob-fade-up var(--ob-duration) var(--ob-ease) both;
}

/* Respect des préférences de réduction de mouvement (accessibilité) */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* -------------------------------------------------------------------
   5. IMPRESSION DU TICKET (@media print) — réutilisable par
      ticket/print.html. Largeur ~80mm, police monospace lisible.
   -------------------------------------------------------------------
   Usage attendu côté ticket :
     - envelopper le ticket dans .ticket-print
     - marquer tout élément à NE PAS imprimer avec la classe .no-print
   ------------------------------------------------------------------- */
@media print {
  /* On masque tout ce qui ne doit pas figurer sur le papier */
  .no-print,
  .no-print * {
    display: none !important;
  }

  /* Réinitialise le fond pour économiser l'encre */
  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    color: #000 !important;
  }

  /* Zone imprimable : largeur ticket de caisse (~80mm) */
  .ticket-print {
    width: 80mm;
    max-width: 80mm;
    margin: 0 auto;
    padding: 4mm 3mm;
    font-family: "Courier New", ui-monospace, monospace;
    font-size: 12px;
    line-height: 1.4;
    color: #000;
    background: #fff;
  }

  /* En-tête du ticket : nom du resto bien lisible */
  .ticket-print .ticket-title {
    text-align: center;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.5px;
    margin: 0 0 2mm;
  }

  .ticket-print .ticket-sub {
    text-align: center;
    font-size: 11px;
    margin: 0 0 3mm;
  }

  /* Séparateurs en pointillés typiques d'un ticket */
  .ticket-print .ticket-sep {
    border: none;
    border-top: 1px dashed #000;
    margin: 2mm 0;
  }

  /* Lignes d'articles : nom à gauche, prix aligné à droite */
  .ticket-print .ticket-line {
    display: flex;
    justify-content: space-between;
    gap: 4mm;
  }

  .ticket-print .ticket-total {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    font-size: 14px;
    margin-top: 2mm;
  }

  .ticket-print .ticket-footer {
    text-align: center;
    font-size: 11px;
    margin-top: 3mm;
  }

  /* Évite les coupures de page malheureuses au milieu d'une ligne */
  .ticket-print .ticket-line,
  .ticket-print .ticket-total {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Supprime les ombres/animations à l'impression */
  * {
    box-shadow: none !important;
    text-shadow: none !important;
    animation: none !important;
    transition: none !important;
  }
}
