/* ══════════════════════════════════════════════════
   design-system.css — Gestion Restauration
   ══════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ── Variables ────────────────────────────────────── */
:root {
  --orange:       #C45F38;
  --orange-light: #FAEEE8;
  --orange-dark:  #9A4220;
  --teal:         #0F6E56;
  --teal-light:   #E1F5EE;
  --blue:         #185FA5;
  --blue-light:   #E6F1FB;
  --amber:        #BA7517;
  --amber-light:  #FAEEDA;
  --green:        #3B6D11;
  --green-light:  #EAF3DE;
  --red:          #C03030;
  --red-light:    #FDEAEA;

  --dark:         #1A1A18;
  --sidebar-bg:   #1C1C1A;
  --sidebar-2:    #252522;
  --gray-600:     #6B6B66;
  --gray-400:     #9A9A94;
  --gray-200:     #D3D1C7;
  --gray-100:     #EEEDE8;
  --gray-50:      #F5F4F0;
  --white:        #FFFFFF;
  --border:       #E0DFD8;

  --font:         'DM Sans', sans-serif;
  --font-mono:    'DM Mono', monospace;

  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    14px;
  --sidebar-w:    220px;
  --topbar-h:     64px;

  --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
  --shadow-md:    0 4px 12px rgba(0,0,0,.10);
}

/* ── Reset ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background:  var(--gray-50);
  color:       var(--dark);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); }

/* ── Layout app ───────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 16px 18px 14px;
  border-bottom: 1px solid #2E2E2B;
}
.sidebar-logo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.sidebar-logo-cmkf {
  height: 32px;
  width: auto;
  object-fit: contain;
  flex: 1;
  min-width: 0;
}
.sidebar-logo-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  margin-left: 10px;
}
.sidebar-logo-name  { font-size: 12px; font-weight: 600; color: #FFF; line-height: 1.3; }
.sidebar-logo-sub   { font-size: 10px; color: var(--gray-600); margin-top: 2px; }
.sidebar-nav        { padding: 14px 10px; flex: 1; }
.sidebar-section    { margin-bottom: 20px; }
.sidebar-label {
  font-size: 9px; font-weight: 700; color: #A0A098;
  letter-spacing: .12em; text-transform: uppercase;
  padding: 0 8px; margin-bottom: 6px; display: block;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px;
  font-size: 13px; color: var(--gray-400);
  margin-bottom: 1px; cursor: pointer;
  transition: background .12s, color .12s;
  user-select: none;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover  { background: var(--sidebar-2); color: #D4D4CC; }
.nav-item.active { background: rgba(196,95,56,.14); color: var(--orange); font-weight: 500; }
.nav-item .icon  { width: 16px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--orange); color: #FFF;
  font-size: 10px; font-weight: 600;
  border-radius: 10px; padding: 1px 6px;
}
.nav-badge.warn { background: var(--amber); }

/* ── Main ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 32px;
  min-height: 100vh;
}

/* ── Topbar page ──────────────────────────────────── */
.page-topbar {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}
.page-topbar h1 { font-size: 22px; font-weight: 600; }
.page-topbar p  { font-size: 13px; color: var(--gray-600); margin-top: 3px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

/* ── Boutons ──────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; border: none;
  transition: opacity .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; }
.btn-primary  { background: var(--orange); color: #FFF; }
.btn-ghost    { background: var(--white); border: 1px solid var(--border); color: #3A3A36; }
.btn-danger   { background: var(--red-light); color: var(--red); border: 1px solid #F5BBBB; }
.btn-sm       { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn-icon     { padding: 7px; border-radius: 7px; }

/* ── Cards ────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--gray-100);
}
.card-title   { font-size: 14px; font-weight: 600; }
.card-link    { font-size: 12px; color: var(--orange); cursor: pointer; }
.card-body    { padding: 16px 20px; }

/* ── KPI cards ────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  padding: 18px;
  position: relative; overflow: hidden;
}
.kpi-accent {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.kpi-label  { font-size: 11px; color: var(--gray-400); text-transform: uppercase; letter-spacing: .05em; font-weight: 500; margin-bottom: 10px; }
.kpi-value  { font-size: 30px; font-weight: 600; line-height: 1; }
.kpi-sub    { font-size: 12px; color: var(--gray-400); margin-top: 6px; }
.kpi-icon   { position: absolute; right: 16px; top: 16px; font-size: 20px; opacity: .12; }

/* ── Tableaux ─────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--gray-50); border-bottom: 2px solid var(--gray-100); }
th {
  padding: 11px 16px; text-align: left;
  font-size: 11px; font-weight: 600; color: var(--gray-400);
  letter-spacing: .05em; text-transform: uppercase;
  white-space: nowrap;
}
th.sort { cursor: pointer; }
th.sort:hover { color: var(--dark); }
tbody tr {
  border-bottom: 1px solid var(--gray-50);
  cursor: pointer;
  transition: background .1s;
}
tbody tr:hover { background: #FAFAF7; }
tbody tr:last-child { border-bottom: none; }
td { padding: 11px 16px; font-size: 13px; vertical-align: middle; }
.td-mono { font-family: var(--font-mono); font-size: 12px; }

/* ── Badges & tags ────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
}
.badge-red    { background: var(--red-light);   color: var(--red);   }
.badge-orange { background: var(--amber-light);  color: var(--amber); }
.badge-green  { background: var(--green-light);  color: var(--green); }
.badge-blue   { background: var(--blue-light);   color: var(--blue);  }
.badge-gray   { background: var(--gray-100);     color: var(--gray-600); }
.tag { font-size: 10px; padding: 1px 6px; border-radius: 4px; }
.tag-vege { background: var(--green-light); color: var(--green); }
.tag-sg   { background: var(--blue-light);  color: var(--blue);  }

/* ── Dot statut ───────────────────────────────────── */
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-red    { background: #E04545; }
.dot-orange { background: #E8973A; }
.dot-green  { background: #45A85A; }
.dot-amber  { background: var(--amber); }

/* ── Inputs ───────────────────────────────────────── */
.input {
  width: 100%; padding: 8px 12px;
  background: var(--gray-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px; font-family: var(--font); color: var(--dark);
  transition: border-color .15s;
  outline: none;
}
.input:focus { border-color: var(--orange); background: var(--white); }
.select-input {
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239A9A94' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.search-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
}
.search-wrap input { border: none; background: transparent; outline: none; font-size: 13px; flex: 1; }
.search-wrap .search-icon { color: var(--gray-400); font-size: 14px; }

/* ── Barre de filtre ──────────────────────────────── */
.filter-bar {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 18px; flex-wrap: wrap;
}
.chip {
  padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); background: var(--white); color: #5A5A54;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.chip.active  { background: var(--orange); color: #FFF; border-color: var(--orange); }
.chip.danger  { background: var(--red-light);   border-color: #F5BBBB; color: var(--red); }
.chip.warning { background: var(--amber-light);  border-color: #F0C97A; color: var(--amber); }

/* ── Grilles layout ───────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-2b { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

/* ── Toast / notification ─────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 1000;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn .2s ease;
}
.toast-success { background: var(--teal); color: #FFF; }
.toast-error   { background: var(--red);  color: #FFF; }
@keyframes toastIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: none; } }

/* ── Loader ───────────────────────────────────────── */
.loader {
  display: flex; align-items: center; justify-content: center;
  padding: 48px; color: var(--gray-400); font-size: 13px; gap: 10px;
}
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--gray-100);
  border-top-color: var(--orange);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Barre de niveau stock ────────────────────────── */
.stock-bar { display: flex; align-items: center; gap: 8px; }
.stock-seg { height: 6px; border-radius: 3px; min-width: 4px; }
.stock-pct { font-size: 11px; font-family: var(--font-mono); color: var(--gray-400); }

/* ── Modale ───────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white); border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,.18);
  width: 480px; max-width: 95vw;
  transform: translateY(12px);
  transition: transform .2s;
  overflow: hidden;
}
.modal-overlay.open .modal { transform: none; }
.modal-head   { padding: 20px 24px 16px; border-bottom: 1px solid var(--gray-100); }
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-head p  { font-size: 12px; color: var(--gray-400); margin-top: 3px; }
.modal-body   { padding: 16px 24px; max-height: 400px; overflow-y: auto; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Vide ─────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Pagination ───────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; }
.page-btn {
  width: 30px; height: 30px; border-radius: 7px;
  font-size: 13px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--white); color: #5A5A54;
  cursor: pointer;
}
.page-btn.active { background: var(--orange); color: #FFF; border-color: var(--orange); }

/* ── Table footer ─────────────────────────────────── */
.table-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-top: 1px solid var(--gray-100);
}
.table-footer span { font-size: 12px; color: var(--gray-400); }

/* ── Form label (Phase 1) ─────────────────────────── */
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 4px;
}

/* ── Modal large ──────────────────────────────────── */
.modal.modal-lg { width: 640px; }

/* ── Textarea dans modal ──────────────────────────── */
.input[rows] {
  height: auto;
  padding: 10px 12px;
}

/* ── Ligne hover table action ─────────────────────── */
tbody tr td .btn { opacity: 1; }
tbody tr:hover td .btn { opacity: 1; }

/* ── Card body padding ────────────────────────────── */
.card-body { padding: 16px 20px; }

/* ── Fiche cuisine — styles impression ───────────────── */
@media print {
  /* Masquer tout l'UI sauf le contenu */
  .sidebar, .no-print, .page-topbar, .toast-container { display: none !important; }
  .main-content { margin: 0 !important; padding: 0 !important; }
  body { background: white !important; font-family: Georgia, serif; }

  /* Forcer les couleurs à l'impression */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  /* Sauts de page */
  .fiche-repas { page-break-inside: avoid; }
  .fiche-entete { page-break-after: avoid; }

  /* Marges page */
  @page {
    margin: 15mm 12mm;
    size: A4 portrait;
  }
}

/* print-only : visible seulement à l'impression */
.print-only { display: none; }
@media print {
  .print-only  { display: inline-block !important; }
  .no-print    { display: none !important; }
  .sorti-check { display: none !important; }
}
