:root {
  --navy: #16264a;
  --navy-dark: #0d1830;
  --red: #c3122e;
  --red-dark: #8f0d22;
  --gold: #b9791f;
  --cream: #f3e9dd;
  --cream-dark: #e7d9c6;
  --ink: #201a14;
  --white: #ffffff;
  --card-bg: linear-gradient(160deg, #fffdf9 0%, #fbf1e2 100%);
  --radius: 14px;
  --shadow: 0 6px 18px rgba(13, 24, 48, 0.18);
}

* { box-sizing: border-box; }

html {
  height: 100%;
}
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Segoe UI", "Trebuchet MS", Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
}

.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  background: linear-gradient(90deg, #dfe8fb 0%, #f2eefc 50%, #fbdfe4 100%);
  border-bottom: 1px solid var(--cream-dark);
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(13,24,48,0.06);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header .logo {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.app-header h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.3px;
  color: var(--navy);
  font-weight: 800;
}

.app-header .subtitle {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: #6b6152;
}

.app-header .header-spacer { flex: 1; }

.badge {
  background: var(--red);
  color: white;
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 700;
  font-size: 0.85rem;
}

a.nav-link {
  color: var(--navy);
  text-decoration: none;
  border: 1px solid var(--cream-dark);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}
a.nav-link:hover { background: var(--cream); border-color: var(--navy); }

button {
  font-family: inherit;
  cursor: pointer;
}

.tricolor-bar {
  height: 6px;
  background: linear-gradient(90deg, var(--navy) 0 33%, var(--white) 33% 66%, var(--red) 66% 100%);
}

/* ---------- Home page ---------- */
.home-wrap {
  max-width: 720px;
  margin: 8vh auto;
  padding: 0 20px;
  text-align: center;
}
.home-wrap h2 { font-size: 1.9rem; margin-bottom: 8px; }
.home-wrap p.lede { color: #4a4237; margin-bottom: 36px; }

.app-footer {
  text-align: center;
  padding: 24px 0 32px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: #9c9280;
}

/* Mobile : les 3 tuiles tiennent sur un seul écran, sans défilement. */
@media (max-width: 480px) {
  .app-header { padding: 10px 16px; gap: 10px; }
  .app-header .logo { width: 34px; height: 34px; }
  .app-header h1 { font-size: 1.08rem; }
  .app-header .subtitle { font-size: 0.72rem; }
  .category-select { top: 58px; }
  .home-wrap { margin: 1.5vh auto 0; padding: 0 16px; }
  .home-wrap h2 { font-size: 1.55rem; margin-bottom: 4px; }
  .home-wrap p.lede { font-size: 0.86rem; margin-bottom: 14px; }
  .role-cards { gap: 12px; }
  .role-card {
    padding: 20px 18px;
  }
  .role-card:hover { transform: none; }
  .role-card .icon {
    width: 68px;
    height: 68px;
    font-size: 2.1rem;
    margin: 0 auto 12px;
  }
  .role-card h3 { font-size: 1.22rem; margin: 0 0 5px; }
  .role-card p { display: block; font-size: 0.82rem; line-height: 1.3; }
  .app-footer { padding: 10px 0 14px; }
}
.role-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}
@media (max-width: 800px) {
  .role-cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .role-cards { grid-template-columns: 1fr; gap: 10px; }
}
.role-card {
  background: linear-gradient(160deg, #eef2fa 0%, #dde6f6 100%);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 20px 22px;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid rgba(22,38,74,0.12);
  border-top: 4px solid var(--navy);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.role-card:nth-child(2) {
  background: linear-gradient(160deg, #fdedf0 0%, #fad9de 100%);
  border-top-color: var(--red);
  border-color: rgba(195,18,46,0.14);
}
.role-card:nth-child(3) {
  background: linear-gradient(160deg, #fdf1e2 0%, #fae2bf 100%);
  border-top-color: var(--gold);
  border-color: rgba(185,121,31,0.18);
}
.role-card:hover { transform: translateY(-5px); box-shadow: 0 14px 28px rgba(13,24,48,0.2); }
.role-card .icon {
  font-size: 2.1rem;
  width: 66px;
  height: 66px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffffff, #fbf6ee);
  box-shadow: 0 4px 10px rgba(13,24,48,0.14);
  transition: transform 0.18s ease;
}
.role-card:hover .icon { transform: scale(1.08) rotate(-4deg); }
.role-card h3 { margin: 0 0 6px; color: var(--navy); font-size: 1.28rem; }
.role-card p { margin: 0; font-size: 0.9rem; color: #5b5344; }

/* ---------- Commande layout ---------- */
.commande-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 0;
  height: calc(100vh - 64px);
}
@media (max-width: 900px) {
  .commande-layout { grid-template-columns: 1fr; height: auto; }
}

.menu-pane {
  overflow-y: auto;
  padding: 18px 20px 90px;
}

/* La page (et non menu-pane) doit être le scroller ici, sinon les éléments
   sticky à l'intérieur de menu-pane s'accrochent à sa propre boîte au lieu
   du viewport réel et se détachent en plein défilement. Placé après la règle
   de base pour bien la remplacer (même spécificité). */
@media (max-width: 900px) {
  .menu-pane { overflow-y: visible; }
}

.category-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 16px;
  position: sticky;
  top: 0;
  background: var(--cream);
  z-index: 5;
}
.category-nav button {
  border: none;
  background: var(--white);
  border: 1px solid var(--cream-dark);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
}
.category-nav button.active {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}

.category-select {
  display: none;
}

@media (max-width: 640px) {
  .category-nav { display: none; }
  .category-select {
    display: block;
    width: 100%;
    position: sticky;
    top: 74px;
    z-index: 5;
    margin: 4px 0 16px;
    padding: 12px 38px 12px 14px;
    border-radius: 999px;
    border: 1px solid var(--cream-dark);
    background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2316264a'%3E%3Cpath d='M5.5 7.5l4.5 4.5 4.5-4.5' stroke='%2316264a' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center;
    background-size: 16px;
    appearance: none;
    -webkit-appearance: none;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--navy);
    box-shadow: var(--shadow);
  }
}

.category-section { margin-bottom: 30px; }
.category-section h2 {
  color: var(--navy);
  border-bottom: 3px solid var(--red);
  display: inline-block;
  padding-bottom: 4px;
  margin: 0 0 14px;
}

/* Chaque catégorie a sa propre teinte, reprise sur les tuiles d'articles
   qu'elle contient (variables lues par .item-card plus bas). */
.category-section.theme-0 { --cat-a: #dfeaff; --cat-b: #c2d9ff; --cat-accent: var(--navy); }
.category-section.theme-1 { --cat-a: #ffe1e6; --cat-b: #ffc3cd; --cat-accent: var(--red); }
.category-section.theme-2 { --cat-a: #fff0cf; --cat-b: #ffdb8f; --cat-accent: var(--gold); }
.category-section.theme-3 { --cat-a: #dcf7e3; --cat-b: #b8edc7; --cat-accent: #2f8a4d; }
.category-section.theme-4 { --cat-a: #ecdffb; --cat-b: #d7bcf5; --cat-accent: #7c3aed; }

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.item-card .thumb {
  width: 100%;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  border-radius: 10px;
  background: rgba(255,255,255,0.55);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6);
  margin-bottom: 4px;
}

.item-card {
  background: linear-gradient(160deg, var(--cat-a, #fffdf9) 0%, var(--cat-b, #fbf1e2) 100%);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(13,24,48,0.08);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid rgba(13,24,48,0.08);
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.item-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--cat-accent, var(--navy));
}
.item-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 26px rgba(13,24,48,0.16);
}
.item-card h4 { margin: 0; color: var(--ink); font-size: 1.04rem; }
.item-card p.desc { margin: 0; font-size: 0.8rem; color: #6b6152; min-height: 2.2em; }
.item-card .price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 8px;
}
.item-card .price {
  font-weight: 800;
  color: var(--red);
  font-size: 0.95rem;
  background: var(--cream);
  padding: 4px 11px;
  border-radius: 999px;
}
.item-card button.add-btn {
  background: linear-gradient(135deg, #ff7a45, #f0402c);
  color: var(--white);
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 3px 10px rgba(240,64,44,0.35);
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.item-card button.add-btn .add-icon {
  font-size: 1rem;
  line-height: 1;
  font-weight: 800;
}
.item-card button.add-btn:hover {
  background: linear-gradient(135deg, #ff8f5f, #ff4d36);
  transform: scale(1.05);
  box-shadow: 0 5px 14px rgba(240,64,44,0.45);
}

/* ---------- Cart sidebar ---------- */
.cart-pane {
  background: var(--white);
  border-left: 3px solid var(--cream-dark);
  display: flex;
  flex-direction: column;
  height: 100%;
}
.cart-header {
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--cream-dark);
}
.cart-header h3 { margin: 0; color: var(--navy); }
.customer-fields {
  padding: 10px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--cream-dark);
}
.customer-fields input, .customer-fields select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--cream-dark);
  font-size: 0.9rem;
}
.cart-lines {
  flex: 1;
  overflow-y: auto;
  padding: 10px 18px;
}
.cart-line {
  border-bottom: 1px dashed var(--cream-dark);
  padding: 10px 0;
}
.cart-line .cl-top {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
}
.cart-line .cl-opts {
  font-size: 0.78rem;
  color: #6b6152;
  margin: 4px 0;
}
.cart-line .cl-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
}
.qty-control button {
  width: 24px; height: 24px;
  border-radius: 6px;
  border: 1px solid var(--cream-dark);
  background: var(--cream);
}
.remove-line {
  color: var(--red);
  font-size: 0.78rem;
  background: none;
  border: none;
  text-decoration: underline;
}
.cart-footer {
  padding: 14px 18px 18px;
  border-top: 2px solid var(--cream-dark);
}
.total-row {
  display: flex;
  justify-content: space-between;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 12px;
}
.total-row .amount { color: var(--red); }
.submit-btn {
  width: 100%;
  padding: 14px;
  background: var(--red);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.submit-btn:disabled { background: #c9beae; cursor: not-allowed; }
.submit-btn:not(:disabled):hover { background: var(--red-dark); }
.empty-cart {
  color: #9c9280;
  text-align: center;
  padding: 30px 10px;
  font-size: 0.9rem;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(13,24,48,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal {
  background: var(--white);
  border-radius: var(--radius);
  max-width: 520px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px 24px;
}
.modal h3 { margin: 0 0 4px; color: var(--navy); }
.modal p.desc { color: #6b6152; margin: 0 0 16px; font-size: 0.88rem; }
.option-group { margin-bottom: 16px; }
.option-group .og-label {
  font-weight: 700;
  color: var(--navy);
  font-size: 0.9rem;
  margin-bottom: 8px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.og-required { color: var(--red); font-size: 0.75rem; font-weight: 700; }
.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.choice-pill {
  border: 1.5px solid var(--cream-dark);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.85rem;
  background: var(--cream);
  color: var(--ink);
}
.choice-pill.selected {
  background: var(--navy);
  border-color: var(--navy);
  color: white;
}
.choice-pill .cp-price {
  opacity: 0.75;
  font-size: 0.78rem;
  margin-left: 4px;
}
.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--cream-dark);
}
.modal-footer .modal-total { font-weight: 800; font-size: 1.15rem; color: var(--red); }
.modal-actions { display: flex; gap: 10px; }
.btn-secondary {
  background: var(--cream);
  border: 1px solid var(--cream-dark);
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
}
.btn-primary {
  background: var(--navy);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 700;
}
.btn-primary:hover { background: var(--red); }

/* ---------- Confirmation ---------- */
.confirm-wrap {
  max-width: 480px;
  margin: 10vh auto;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 28px;
  text-align: center;
}
.confirm-wrap .big-check { font-size: 3rem; }
.confirm-wrap h2 { color: var(--navy); margin: 6px 0; }
.confirm-wrap .order-id { color: #6b6152; margin-bottom: 18px; }
.confirm-wrap .amount-due {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--red);
  margin: 10px 0 24px;
}
.confirm-wrap .pay-note {
  background: var(--cream);
  border-radius: 10px;
  padding: 14px;
  font-size: 0.9rem;
  color: #4a4237;
  margin-bottom: 22px;
}

/* ---------- Kitchen screen ---------- */
.kitchen-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 18px;
  height: calc(100vh - 76px);
}
@media (max-width: 1000px) {
  .kitchen-board { grid-template-columns: 1fr; height: auto; }
}
.kitchen-col {
  background: rgba(255,255,255,0.6);
  border-radius: var(--radius);
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.kitchen-col h2 {
  margin: 0 0 4px;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--navy);
  display: flex;
  justify-content: space-between;
}
.col-nouveau { border-top: 5px solid var(--red); }
.col-preparation { border-top: 5px solid #c98a12; }
.col-pret { border-top: 5px solid #1c8a4a; }

.ticket {
  background: white;
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  border-left: 6px solid var(--navy);
  animation: pop-in 0.25s ease;
}
@keyframes pop-in {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.ticket.nouveau { border-left-color: var(--red); }
.ticket.en_preparation { border-left-color: #c98a12; }
.ticket.pret { border-left-color: #1c8a4a; }

.ticket .t-top {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  color: var(--navy);
}
.ticket .t-meta {
  font-size: 0.75rem;
  color: #8a8070;
  margin-bottom: 8px;
}
.ticket .t-line { font-size: 0.88rem; margin-bottom: 6px; }
.ticket .t-line .qty { font-weight: 800; color: var(--red); margin-right: 4px; }
.ticket .t-line .opts { font-size: 0.76rem; color: #6b6152; margin-left: 18px; }
.ticket .t-actions { display: flex; gap: 8px; margin-top: 10px; }
.ticket .t-actions button {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 8px;
  font-weight: 700;
  font-size: 0.8rem;
}
.ticket .t-actions .btn-advance { background: var(--red); color: white; }
.ticket .t-actions .btn-advance:hover { background: var(--red-dark); }
.ticket.pret .t-actions .btn-advance { background: #1c8a4a; }
.ticket.pret .t-actions .btn-advance:hover { background: #146638; }
.ticket .t-actions .btn-cancel { background: transparent; color: #b5473d; text-decoration: underline; font-weight: 600; }
.empty-col { color: #9c9280; font-size: 0.85rem; text-align: center; padding: 20px 6px; }
.conn-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #59d67a;
  display: inline-block;
  margin-right: 6px;
}
.conn-dot.off { background: #d65959; }
