/* PharmaGest — identité « officine » : vert pin, vert croix de pharmacie, ambre péremption */
:root {
  --pg-pine: #0f3d3e;
  --pg-pine-2: #15504f;
  --pg-cross: #12a37f;
  --pg-cross-dark: #0c7c61;
  --pg-paper: #f5f8f7;
  --pg-ink: #1e2a2b;
  --pg-muted: #5f6f70;
  --pg-line: #dbe4e2;
  --pg-amber: #e8a33d;
  --pg-red: #d64545;
  --pg-sidebar-w: 256px;

  --bs-primary: var(--pg-cross);
  --bs-primary-rgb: 18, 163, 127;
  --bs-body-font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bs-body-color: var(--pg-ink);
  --bs-body-bg: var(--pg-paper);
  --bs-border-color: var(--pg-line);
  --bs-link-color: var(--pg-cross-dark);
  --bs-link-hover-color: var(--pg-pine);
}

body { font-size: .925rem; font-feature-settings: "tnum" 1; }
.num, .table td, .kpi-value { font-variant-numeric: tabular-nums; }
h1, .h1, h2, .h2, h3, .h3 { font-weight: 650; letter-spacing: -.01em; }
.page-title { font-size: 1.45rem; margin: 0; }
.text-muted { color: var(--pg-muted) !important; }
:focus-visible { outline: 3px solid rgba(18, 163, 127, .55); outline-offset: 2px; }

/* Boutons */
.btn-primary { --bs-btn-bg: var(--pg-cross); --bs-btn-border-color: var(--pg-cross); --bs-btn-hover-bg: var(--pg-cross-dark); --bs-btn-hover-border-color: var(--pg-cross-dark); --bs-btn-active-bg: var(--pg-cross-dark); --bs-btn-disabled-bg: var(--pg-cross); --bs-btn-disabled-border-color: var(--pg-cross); }
.btn-outline-primary { --bs-btn-color: var(--pg-cross-dark); --bs-btn-border-color: var(--pg-cross); --bs-btn-hover-bg: var(--pg-cross); --bs-btn-hover-border-color: var(--pg-cross); --bs-btn-active-bg: var(--pg-cross-dark); }
.btn-pine { --bs-btn-color: #fff; --bs-btn-bg: var(--pg-pine); --bs-btn-border-color: var(--pg-pine); --bs-btn-hover-bg: var(--pg-pine-2); --bs-btn-hover-color: #fff; }
.form-control:focus, .form-select:focus { border-color: var(--pg-cross); box-shadow: 0 0 0 .2rem rgba(18, 163, 127, .18); }
.form-check-input:checked { background-color: var(--pg-cross); border-color: var(--pg-cross); }

/* Barre latérale */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--pg-sidebar-w); z-index: 1040;
  background: var(--pg-pine); color: #cfe3df; display: flex; flex-direction: column;
  transition: transform .2s ease;
}
.sidebar .brand { display: flex; align-items: center; gap: .65rem; padding: 1.1rem 1.25rem; color: #fff; text-decoration: none; }
.sidebar .brand-cross { width: 34px; height: 34px; flex: none; }
.sidebar .brand-name { font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.sidebar .brand-sub { font-size: .75rem; color: #8fb6ae; }
.sidebar nav { overflow-y: auto; padding: .25rem .75rem 1rem; flex: 1; }
.sidebar .nav-group { font-size: .74rem; color: #7fa59d; margin: 1rem .6rem .35rem; font-weight: 600; }
.sidebar .nav-link { color: #d5e7e3; border-radius: 8px; padding: .48rem .65rem; display: flex; align-items: center; gap: .65rem; font-size: .9rem; }
.sidebar .nav-link i { font-size: 1.05rem; opacity: .85; width: 1.1rem; text-align: center; }
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar .nav-link.active { background: var(--pg-cross); color: #fff; font-weight: 600; }
.sidebar .nav-link .badge { margin-left: auto; }
.sidebar .sidebar-foot { padding: .9rem 1.25rem; border-top: 1px solid rgba(255, 255, 255, .08); font-size: .8rem; }

.main { margin-left: var(--pg-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1030; background: rgba(245, 248, 247, .92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--pg-line); padding: .6rem 1.5rem; display: flex; align-items: center; gap: 1rem; }
.content { padding: 1.5rem; flex: 1; }
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .main { margin-left: 0; }
  .content { padding: 1rem; }
  .topbar { padding: .6rem 1rem; }
}

/* Indicateur réseau */
.net-pill { font-size: .78rem; border-radius: 999px; padding: .2rem .65rem; display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--pg-line); background: #fff; }
.net-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pg-cross); }
.net-pill.offline { background: #fff4e3; border-color: #f2cf97; color: #7a4b07; }
.net-pill.offline .dot { background: var(--pg-amber); }

/* Panneaux */
.panel { background: #fff; border: 1px solid var(--pg-line); border-radius: 12px; }
.panel-head { padding: .9rem 1.1rem; border-bottom: 1px solid var(--pg-line); display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.panel-head h2, .panel-head h3 { font-size: 1rem; margin: 0; }
.panel-body { padding: 1.1rem; }
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > thead th { font-size: .78rem; color: var(--pg-muted); font-weight: 600; border-bottom-width: 1px; white-space: nowrap; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f0f6f4; }

/* Indicateurs du tableau de bord */
.kpi { padding: 1.1rem 1.2rem; background: #fff; border: 1px solid var(--pg-line); border-radius: 12px; height: 100%; }
.kpi-label { font-size: .82rem; color: var(--pg-muted); }
.kpi-value { font-family: "Bricolage Grotesque", var(--bs-body-font-family); font-size: 1.7rem; font-weight: 700; line-height: 1.15; margin-top: .25rem; letter-spacing: -.02em; }
.kpi-value small { font-size: .55em; font-weight: 600; color: var(--pg-muted); }
.kpi-foot { font-size: .8rem; margin-top: .35rem; }
.kpi.kpi-hero { background: var(--pg-pine); color: #fff; border-color: var(--pg-pine); }
.kpi.kpi-hero .kpi-label, .kpi.kpi-hero .kpi-value small { color: #9fc7bf; }
.trend-up { color: var(--pg-cross-dark); }
.trend-down { color: var(--pg-red); }
.kpi-hero .trend-up { color: #6ee7c4; }
.kpi-hero .trend-down { color: #ffb4b4; }

/* Étagère de péremption (élément signature) */
.shelf { display: grid; grid-template-columns: var(--c-perime, 1fr) var(--c30, 1fr) var(--c60, 1fr) var(--c90, 1fr); gap: 4px; height: 54px; }
.shelf > a { border-radius: 6px; color: #fff; text-decoration: none; display: flex; flex-direction: column; justify-content: center; padding: 0 .75rem; min-width: 64px; transition: filter .15s; }
.shelf > a:hover { filter: brightness(1.08); }
.shelf .s-perime { background: #3a2f2f; }
.shelf .s30 { background: var(--pg-red); }
.shelf .s60 { background: var(--pg-amber); color: #3b2604; }
.shelf .s90 { background: #7cc5b0; color: #08372c; }
.shelf strong { font-family: "Bricolage Grotesque", sans-serif; font-size: 1.25rem; line-height: 1; }
.shelf span { font-size: .74rem; opacity: .9; }

/* Statuts */
.badge-soft { font-weight: 600; border-radius: 6px; padding: .3em .55em; }
.bg-soft-success { background: #ddf3ec; color: #0b6b53; }
.bg-soft-warning { background: #fdf0d9; color: #8a5806; }
.bg-soft-danger { background: #fbe3e3; color: #a12c2c; }
.bg-soft-info { background: #e1eff8; color: #1f5b82; }
.bg-soft-secondary { background: #eceff0; color: #4c5859; }
.bg-soft-dark { background: #e3e3e3; color: #222; }

/* Caisse POS */
.pos { display: grid; grid-template-columns: 1fr 420px; gap: 1rem; min-height: calc(100vh - 120px); }
@media (max-width: 1199.98px) { .pos { grid-template-columns: 1fr; } }
.pos-search { position: relative; }
.pos-search input { font-size: 1.15rem; padding: .85rem 1rem .85rem 3rem; border-radius: 12px; border: 2px solid var(--pg-line); }
.pos-search input:focus { border-color: var(--pg-cross); }
.pos-search > i { position: absolute; left: 1.05rem; top: 50%; transform: translateY(-50%); font-size: 1.25rem; color: var(--pg-muted); }
.pos-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem; margin-top: 1rem; }
.prod-tile { text-align: left; background: #fff; border: 1px solid var(--pg-line); border-radius: 10px; padding: .75rem .8rem; cursor: pointer; transition: border-color .12s, transform .12s; }
.prod-tile:hover, .prod-tile:focus-visible { border-color: var(--pg-cross); }
.prod-tile:active { transform: scale(.98); }
.prod-tile .p-name { font-weight: 650; line-height: 1.2; }
.prod-tile .p-dci { font-size: .78rem; color: var(--pg-muted); }
.prod-tile .p-price { font-family: "Bricolage Grotesque", sans-serif; font-weight: 700; color: var(--pg-pine); margin-top: .35rem; }
.prod-tile.disabled { opacity: .45; cursor: not-allowed; }
.cart { background: #fff; border: 1px solid var(--pg-line); border-radius: 14px; display: flex; flex-direction: column; position: sticky; top: 76px; max-height: calc(100vh - 100px); }
.cart-lines { overflow-y: auto; flex: 1; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: .25rem .75rem; padding: .7rem 1rem; border-bottom: 1px solid #edf2f1; }
.cart-line .qty { display: inline-flex; align-items: center; border: 1px solid var(--pg-line); border-radius: 8px; overflow: hidden; }
.cart-line .qty button { border: 0; background: #f3f7f6; width: 30px; height: 30px; }
.cart-line .qty input { width: 48px; border: 0; text-align: center; height: 30px; }
.cart-total { padding: 1rem; border-top: 2px dashed var(--pg-line); }
.cart-total .grand { font-family: "Bricolage Grotesque", sans-serif; font-size: 2rem; font-weight: 800; color: var(--pg-pine); letter-spacing: -.02em; }
.pay-modes .btn-check + .btn { min-width: 0; }
.kbd { font-size: .72rem; border: 1px solid var(--pg-line); border-bottom-width: 2px; border-radius: 4px; padding: 0 .3rem; color: var(--pg-muted); background: #fff; }

/* Connexion */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { background: var(--pg-pine); color: #d5e7e3; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side .big-cross { position: absolute; right: -80px; bottom: -80px; width: 420px; opacity: .09; }
.auth-side h1 { color: #fff; font-family: "Bricolage Grotesque", sans-serif; font-size: 2.6rem; font-weight: 800; letter-spacing: -.03em; max-width: 14ch; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-form form { width: 100%; max-width: 380px; }
@media (max-width: 767.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }

/* Impression */
@media print {
  .sidebar, .topbar, .no-print, .btn { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  .panel { border: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
