/* PetRest Démo — style sobre, doux et rassurant (vert / gris) */

:root {
  --green-900: #1f4433;
  --green-700: #2f6b4f;
  --green-500: #4c9a76;
  --green-300: #9ccbb4;
  --green-100: #e7f2ec;
  --green-50:  #f3f9f6;

  --gray-900: #23282b;
  --gray-700: #4a5359;
  --gray-500: #7a848b;
  --gray-300: #cdd4d8;
  --gray-200: #e3e8ea;
  --gray-100: #f1f4f5;
  --white: #ffffff;

  --amber: #c98a1e;
  --amber-bg: #fbf1dd;
  --red: #c0463b;
  --red-bg: #fbe6e3;
  --blue: #3b6fb0;
  --blue-bg: #e6eef8;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(31,68,51,.06), 0 6px 20px rgba(31,68,51,.06);
  --shadow-lg: 0 10px 40px rgba(31,68,51,.18);
  --sidebar-w: 250px;
  --banner-h: 34px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--gray-900);
  background: var(--green-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Bandeau démo ---------- */
.demo-banner {
  position: fixed; top: 0; left: 0; right: 0; height: var(--banner-h);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--green-900); color: #dff0e7;
  font-size: 12.5px; letter-spacing: .3px; z-index: 60;
}
.demo-banner .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green-300); animation: pulse 2.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; padding-top: var(--banner-h); }

.sidebar {
  position: fixed; top: var(--banner-h); bottom: 0; left: 0; width: var(--sidebar-w);
  background: var(--white); border-right: 1px solid var(--gray-200);
  display: flex; flex-direction: column; z-index: 50; transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px 14px; }
.brand-mark { font-size: 26px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 18px; color: var(--green-900); }
.brand-text small { color: var(--gray-500); font-size: 11px; }

.nav { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 11px 12px;
  border-radius: var(--radius-sm); text-decoration: none; color: var(--gray-700);
  font-size: 14.5px; font-weight: 500; transition: background .15s, color .15s;
}
.nav-item .ico { font-size: 16px; width: 20px; text-align: center; }
.nav-item:hover { background: var(--green-50); color: var(--green-900); }
.nav-item.active { background: var(--green-100); color: var(--green-900); }
.sidebar-foot { padding: 14px 18px; border-top: 1px solid var(--gray-200); color: var(--gray-500); }

.overlay {
  position: fixed; inset: 0; background: rgba(31,68,51,.35); z-index: 45;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.overlay.show { opacity: 1; pointer-events: auto; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: var(--banner-h); z-index: 40;
  display: flex; align-items: center; gap: 14px;
  background: rgba(243,249,246,.9); backdrop-filter: blur(6px);
  padding: 14px 24px; border-bottom: 1px solid var(--gray-200);
}
.burger { display: none; border: none; background: transparent; font-size: 22px; cursor: pointer; color: var(--green-900); }
.page-title { font-size: 20px; margin: 0; color: var(--green-900); font-weight: 650; }
.topbar-right { margin-left: auto; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--gray-700); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--green-500); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; }

.content { padding: 24px; max-width: 1200px; width: 100%; }

/* ---------- Cartes / grilles ---------- */
.grid { display: grid; gap: 18px; }
.kpi-grid { grid-template-columns: repeat(4, 1fr); }
.two-col { grid-template-columns: 1.4fr 1fr; align-items: start; }

.card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.card h2, .card h3 { margin: 0 0 4px; color: var(--green-900); }
.card h2 { font-size: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.section-head h2 { font-size: 17px; margin: 0; color: var(--green-900); }
.muted { color: var(--gray-500); font-size: 13px; }

.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi .kpi-ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 20px; background: var(--green-100); }
.kpi .kpi-value { font-size: 30px; font-weight: 700; color: var(--green-900); line-height: 1; }
.kpi .kpi-label { color: var(--gray-500); font-size: 13px; }
.kpi.alert .kpi-ico { background: var(--red-bg); }
.kpi.alert .kpi-value { color: var(--red); }

/* ---------- Timeline circuit ---------- */
.circuit { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.circuit-col { background: var(--green-50); border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: 10px; min-height: 120px; }
.circuit-col h4 { margin: 0 0 10px; font-size: 13px; color: var(--green-700); display: flex; align-items: center; gap: 6px; }
.circuit-col h4 .count { margin-left: auto; background: var(--white); border: 1px solid var(--gray-200); border-radius: 20px; font-size: 11px; padding: 1px 8px; color: var(--gray-500); }
.pet-chip { background: var(--white); border: 1px solid var(--gray-200); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; box-shadow: var(--shadow); }
.pet-chip .pet-top { display: flex; justify-content: space-between; align-items: center; }
.pet-chip strong { color: var(--gray-900); }
.pet-chip .pet-meta { color: var(--gray-500); font-size: 11.5px; margin-top: 2px; display: flex; justify-content: space-between; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.b-green { background: var(--green-100); color: var(--green-700); }
.badge.b-blue { background: var(--blue-bg); color: var(--blue); }
.badge.b-amber { background: var(--amber-bg); color: var(--amber); }
.badge.b-red { background: var(--red-bg); color: var(--red); }
.badge.b-gray { background: var(--gray-100); color: var(--gray-500); }

/* ---------- Tables ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.input, .select {
  font-family: inherit; font-size: 14px; color: var(--gray-900);
  background: var(--white); border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
  padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus { border-color: var(--green-500); box-shadow: 0 0 0 3px var(--green-100); }
.input { flex: 1; min-width: 180px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--gray-200); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th { text-align: left; background: var(--green-50); color: var(--green-700); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--gray-200); white-space: nowrap; position: sticky; top: 0; }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; transition: background .12s; }
tbody tr.clickable:hover { background: var(--green-50); }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; color: var(--gray-700); }
.empty-row td { text-align: center; color: var(--gray-500); padding: 26px; }

/* ---------- Panneau de détail (drawer) ---------- */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 92vw; background: var(--white); box-shadow: var(--shadow-lg); z-index: 70; transform: translateX(100%); transition: transform .28s ease; display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 20px; border-bottom: 1px solid var(--gray-200); display: flex; justify-content: space-between; align-items: flex-start; }
.drawer-head h3 { margin: 0 0 4px; color: var(--green-900); font-size: 18px; }
.drawer-close { border: none; background: var(--gray-100); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 16px; color: var(--gray-700); }
.drawer-body { padding: 20px; overflow-y: auto; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-bottom: 20px; }
.detail-grid .lbl { font-size: 11.5px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .4px; }
.detail-grid .val { font-size: 14px; color: var(--gray-900); font-weight: 500; }

.timeline { list-style: none; margin: 8px 0 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--gray-200); }
.timeline li { position: relative; padding: 0 0 18px 32px; }
.timeline li::before { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--green-500); border: 3px solid var(--green-100); }
.timeline li.pending::before { background: var(--gray-300); border-color: var(--gray-100); }
.timeline .tl-type { font-weight: 600; font-size: 14px; color: var(--gray-900); }
.timeline .tl-meta { font-size: 12.5px; color: var(--gray-500); }

/* ---------- Extranet vétérinaire ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; color: var(--gray-700); font-weight: 600; }
.product-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.product { border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: hidden; background: var(--white); cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .1s; }
.product:hover { box-shadow: var(--shadow); }
.product.selected { border-color: var(--green-500); box-shadow: 0 0 0 3px var(--green-100); }
.product .thumb { height: 96px; background: linear-gradient(135deg, var(--green-100), var(--green-300)); display: grid; place-items: center; font-size: 34px; color: var(--green-900); }
.product .p-body { padding: 12px; }
.product .p-name { font-weight: 600; font-size: 14px; color: var(--gray-900); }
.product .p-desc { font-size: 12px; color: var(--gray-500); margin: 4px 0 8px; min-height: 32px; }
.product .p-foot { display: flex; justify-content: space-between; align-items: center; }
.product .p-dims { font-size: 11.5px; color: var(--gray-500); }
.product .p-price { font-weight: 700; color: var(--green-700); }
.product .check { display: inline-block; }

.invoice { position: sticky; top: 88px; }
.invoice ul { list-style: none; margin: 0; padding: 0; }
.invoice li { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--gray-200); font-size: 13.5px; }
.invoice li .rm { color: var(--red); cursor: pointer; border: none; background: none; font-size: 15px; line-height: 1; }
.invoice .total { display: flex; justify-content: space-between; font-size: 18px; font-weight: 700; color: var(--green-900); margin-top: 12px; }
.invoice .empty { color: var(--gray-500); font-size: 13px; padding: 8px 0; }

.btn { font-family: inherit; font-size: 14px; font-weight: 600; padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; transition: background .15s, box-shadow .15s; }
.btn-primary { background: var(--green-700); color: #fff; }
.btn-primary:hover { background: var(--green-900); }
.btn-ghost { background: var(--white); border-color: var(--gray-300); color: var(--gray-700); }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--green-900); color: #eaf5ef; padding: 12px 20px; border-radius: 40px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 80; font-size: 14px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- I-CAD résumé ---------- */
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }

/* ---------- Barre de progression stock ---------- */
.stock-bar { height: 7px; border-radius: 6px; background: var(--gray-200); overflow: hidden; min-width: 90px; }
.stock-bar > span { display: block; height: 100%; border-radius: 6px; background: var(--green-500); }
.stock-bar.low > span { background: var(--red); }
.row-critical { background: var(--red-bg) !important; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .circuit { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .burger { display: block; }
  .content { padding: 16px; }
  .form-grid, .product-grid, .kpi-grid, .detail-grid { grid-template-columns: 1fr; }
  .circuit { grid-template-columns: 1fr; }
  .mini-stats { grid-template-columns: 1fr; }
  .drawer { width: 100%; }
}
