/* ============================================================
   POSFood — styles.css
   Variables de thème, animations et composants
   ============================================================ */

:root {
  --page: #DAD9DD;
  --app: #15161F;
  --sidebar: #171820;
  --card: #1D1E27;
  --card-hover: #24252F;
  --input: #1F2029;
  --panel: #181920;
  --summary: #20212B;
  --border: #2A2B35;
  --divider: #30313A;
  --primary: #FF555B;
  --primary-hover: #FF696E;
  --white: #F5F5F7;
  --text-2: #8B8C96;
  --text-3: #62636D;
  --shadow: 0 25px 60px rgba(0, 0, 0, .35);
}

html.light {
  --page: #EFEEF2;
  --app: #FFFFFF;
  --sidebar: #F7F7F9;
  --card: #F4F4F6;
  --card-hover: #ECECF0;
  --input: #F1F1F4;
  --panel: #FAFAFB;
  --summary: #F2F2F5;
  --border: #E2E2E8;
  --divider: #E6E6EC;
  --primary: #F0353C;
  --primary-hover: #D92A31;
  --white: #15161F;
  --text-2: #6C6D78;
  --text-3: #8E8F9A;
  --shadow: 0 25px 60px rgba(20, 20, 40, .14);
}

* { font-family: 'Inter', Arial, sans-serif; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--app);
  transition: background .4s ease;
}

/* L'application occupe toute la fenêtre */
#pos-app {
  background: var(--app);
  width: 100vw;
  height: 100vh;
  transition: background .4s ease;
}

/* Tableaux des écrans de gestion */
#page-view input[type=number]::-webkit-inner-spin-button { opacity: .35; }
#page-view tr:hover > td { background: var(--card); }

.t { transition: all .15s ease; }

/* ---------- Scrollbars discrètes ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--divider); border-radius: 9px; }
.scroll-area { scrollbar-width: thin; scrollbar-color: var(--divider) transparent; }

/* ---------- Animations ---------- */
@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(.93); }
  100% { transform: scale(1); }
}
.pop { animation: pop .28s cubic-bezier(.34, 1.56, .64, 1); }

@keyframes bounceIn {
  0% { transform: scale(0) rotate(-25deg); opacity: 0; }
  60% { transform: scale(1.25) rotate(6deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.bounce-in { animation: bounceIn .45s cubic-bezier(.34, 1.56, .64, 1); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(26px) scale(.94); }
  to { opacity: 1; transform: none; }
}
.slide-in { animation: slideIn .32s cubic-bezier(.22, 1, .36, 1); }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.rise { animation: rise .38s cubic-bezier(.22, 1, .36, 1) backwards; }

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  30%, 70% { transform: translateX(4px); }
  50% { transform: translateX(-4px); }
}
.shake { animation: shake .4s ease; }

@keyframes sparkle {
  0% { transform: scale(0) rotate(0); opacity: 1; }
  100% { transform: scale(1.6) rotate(160deg); opacity: 0; }
}
.spark {
  position: fixed;
  pointer-events: none;
  z-index: 90;
  font-size: 13px;
  animation: sparkle .65s ease-out forwards;
}

.flyer {
  position: fixed;
  z-index: 100;
  border-radius: 10px;
  object-fit: cover;
  pointer-events: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}

/* ---------- Composants ---------- */
.card:hover { transform: translateY(-3px); background: var(--card-hover); }
.card:active { transform: translateY(-1px) scale(.985); }

.cat.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 85, 91, .13);
}

.btn-primary { background: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0) scale(.98); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Placeholder si l'image du plat ne charge pas */
.ph {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  background: linear-gradient(135deg, #3a2a24, #211a19);
}
html.light .ph { background: linear-gradient(135deg, #f7e2d3, #efd2c0); }

#drawer-back { backdrop-filter: blur(3px); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ============================================================
   Formulaire modal (ajout / modification d'un plat)
   ============================================================ */
#modal-back {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#modal-back.hidden { display: none; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(18px) scale(.97); }
  to { opacity: 1; transform: none; }
}
#modal-box {
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 14px;
  background: var(--app);
  border: 1px solid var(--border);
  animation: modalIn .26s cubic-bezier(.22, 1, .36, 1);
}

.form-input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 8px;
  outline: none;
  background: var(--input);
  border: 1px solid var(--border);
  color: var(--white);
  transition: border-color .15s ease;
}
.form-input:focus { border-color: var(--primary); }
select.form-input { cursor: pointer; }
.form-label {
  display: block;
  font-size: 10px;
  margin-bottom: 4px;
  color: var(--text-3);
}

/* ============================================================
   Bouton flottant — mobile uniquement
   ============================================================ */
#fab {
  position: fixed;
  right: 16px;
  bottom: 84px;
  z-index: 45;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 8px 24px rgba(255, 85, 91, .45);
}
#fab.show { display: flex; }
@media (min-width: 768px) { #fab { display: none !important; } }

/* ============================================================
   Responsive — la barre latérale passe en bas sur téléphone
   ============================================================ */
@media (max-width: 767px) {
  #pos-app { flex-direction: column; }

  #sidebar {
    order: 3;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
  }
  #sidebar .brand { display: none; }
  #sidebar nav {
    flex: 1;
    flex-direction: row;
    justify-content: space-around;
    gap: 2px;
  }
  #sidebar .nav-item { width: auto; min-width: 44px; padding: 5px 2px; }
  #theme-btn { margin-top: 0; }
  #theme-label { display: none; }

  main { order: 1; flex: 1; min-height: 0; }

  header { padding: 10px 12px 8px; }
  #today { display: none; }

  #categories, #products, #page-view { padding-left: 12px; padding-right: 12px; }
  #products { gap: 8px; }

  #order-panel { width: min(320px, 88vw); }
}

/* Tablette : la sidebar reste, la grille respire */
@media (min-width: 768px) and (max-width: 1023px) {
  #order-panel { width: min(320px, 86vw); }
}

/* Sortie douce d'une ligne du panier */
@keyframes slideOut {
  to { opacity: 0; transform: translateX(24px) scale(.94); }
}
.slide-out { animation: slideOut .18s ease forwards; }

/* Les lignes du panier ne rejouent pas leur animation à chaque rendu */
.cart-line { transition: background .15s ease; }

/* ============================================================
   Rideau — écran de veille et connexion
   Le panneau tombe du haut, touche le bas, puis rebondit
   quatre fois de moins en moins haut, comme sur un trampoline.
   ============================================================ */

#curtain {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: rgba(8, 9, 14, .58);
  backdrop-filter: blur(6px);
}
#curtain.hidden { display: none; }

@keyframes curtainDrop {
  /* la chute */
  0%   { transform: translateY(-105%); }
  38%  { transform: translateY(0); }

  /* rebond 1 — le plus ample */
  48%  { transform: translateY(-16%); }
  58%  { transform: translateY(0); }

  /* rebond 2 */
  66%  { transform: translateY(-8%); }
  74%  { transform: translateY(0); }

  /* rebond 3 */
  80%  { transform: translateY(-3.5%); }
  86%  { transform: translateY(0); }

  /* rebond 4 — presque imperceptible */
  91%  { transform: translateY(-1.2%); }
  95%  { transform: translateY(0); }
  98%  { transform: translateY(-0.4%); }
  100% { transform: translateY(0); }
}

/* Chute rapide, rebonds amortis : la courbe change au milieu */
#curtain-panel {
  width: 100%;
  max-width: 440px;
  margin-top: max(4vh, 18px);
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 18px;
  background: var(--app);
  border: 1px solid var(--border);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .5);
  animation: curtainDrop 1.15s cubic-bezier(.33, 0, .25, 1) both;
}

/* Petit écrasement à l'impact, pour appuyer la sensation de poids */
@keyframes curtainSquash {
  0%, 34%  { transform: scaleY(1) scaleX(1); }
  40%      { transform: scaleY(.94) scaleX(1.03); }
  47%      { transform: scaleY(1.02) scaleX(.99); }
  56%      { transform: scaleY(1) scaleX(1); }
  100%     { transform: scaleY(1) scaleX(1); }
}
#curtain-inner {
  display: block;
  transform-origin: center top;
  animation: curtainSquash 1.15s cubic-bezier(.33, 0, .25, 1) both;
}

/* ---------- Pavé numérique tactile ---------- */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.key {
  height: 56px;
  border-radius: 12px;
  font-size: 20px;
  font-weight: 600;
  background: var(--summary);
  color: var(--white);
  transition: transform .08s ease, background .15s ease;
}
.key:active { transform: scale(.94); background: var(--card-hover); }
.key.wide { grid-column: span 1; font-size: 13px; font-weight: 500; color: var(--text-2); }

/* ---------- Points du PIN ---------- */
.pin-dots { display: flex; gap: 12px; justify-content: center; }
.pin-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--border);
  transition: all .18s cubic-bezier(.34, 1.56, .64, 1);
}
.pin-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
  transform: scale(1.18);
}

/* ---------- Choix de la servante ---------- */
.server-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--summary);
  color: var(--white);
  transition: all .15s ease;
}
.server-btn:hover { background: var(--card-hover); transform: translateX(3px); }
.server-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  flex-shrink: 0;
}

/* Horloge de l'écran de veille */
.idle-clock {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}