/* ============================================================
   PRIASDIVA — Design tokens
   Palette maroquinerie: cuir, laiton, papier crème
   ============================================================ */
:root{
  --bg:            #F6F1E7;
  --bg-alt:        #EFE6D3;
  --paper:         #FFFDF9;
  --ink:           #26201C;
  --ink-soft:      #6B5F52;
  --line:          #DDD2BC;
  --wine:          #7A3347;
  --wine-dark:     #5C2536;
  --brass:         #B8935A;
  --brass-light:   #D8BD8D;
  --danger:        #A33B2B;
  --danger-bg:     #F6E2DC;
  --warning:       #8A6415;
  --warning-bg:    #F5E7C6;
  --success:       #4B6B4F;
  --success-bg:    #E2EADF;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  --radius-s: 6px;
  --radius-m: 12px;
  --shadow: 0 2px 10px rgba(38,32,28,0.06), 0 1px 2px rgba(38,32,28,0.08);
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4{
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 4px 0;
  letter-spacing: -0.01em;
}
.num{ font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
button{ font-family: inherit; cursor:pointer; }
a{ color: inherit; }
:focus-visible{ outline: 2px solid var(--wine); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- App shell ---------- */
#app{
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--line);
}
.brand-mark{
  width:38px; height:38px;
  border-radius:50%;
  background: var(--wine);
  border: 2px solid var(--brass);
  display:flex; align-items:center; justify-content:center;
  color: var(--bg);
  font-family: var(--font-display);
  font-weight:700;
  font-size: 15px;
  flex-shrink:0;
}
.brand-text{ line-height:1.15; }
.brand-text .name{ font-family: var(--font-display); font-size: 19px; font-weight:600; }
.brand-text .tag{ font-size: 11px; color: var(--ink-soft); text-transform:uppercase; letter-spacing:.08em; }

/* ---------- Sidebar nav ---------- */
.sidebar{
  background: var(--paper);
  border-right: 1px solid var(--line);
  display:flex;
  flex-direction:column;
  position: sticky;
  top:0;
  height:100vh;
}
.nav{
  flex:1;
  padding: 10px 12px;
  display:flex;
  flex-direction:column;
  gap: 2px;
}
.nav-item{
  display:flex;
  align-items:center;
  gap:12px;
  padding: 11px 14px;
  border-radius: var(--radius-s);
  border:none;
  background:transparent;
  color: var(--ink-soft);
  font-size: 14.5px;
  font-weight:500;
  text-align:left;
  width:100%;
}
.nav-item .ic{ font-size:16px; width:18px; text-align:center; }
.nav-item:hover{ background: var(--bg-alt); color: var(--ink); }
.nav-item.active{
  background: var(--wine);
  color: #fff;
}
.nav-item .badge-count{
  margin-left:auto;
  background: var(--danger);
  color:#fff;
  font-size: 10.5px;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 20px;
}
.nav-item.active .badge-count{ background: rgba(255,255,255,.25); }

.sidebar-foot{
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-soft);
}
.status-dot{
  display:inline-block; width:7px; height:7px; border-radius:50%;
  background: var(--success); margin-right:6px;
}
.status-dot.off{ background: var(--ink-soft); }

/* ---------- Main area ---------- */
main{
  padding: 30px 34px 60px;
  max-width: 1180px;
  width: 100%;
}
.view{ display:none; }
.view.active{ display:block; animation: fadein .25s ease; }
@keyframes fadein{ from{opacity:0; transform: translateY(4px);} to{opacity:1; transform:none;} }

.view-head{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap:wrap;
}
.view-head h2{ font-size: 26px; }
.view-head p{ margin:0; color: var(--ink-soft); font-size: 13.5px; }

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; gap:7px;
  padding: 10px 18px;
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  transition: transform .08s ease, box-shadow .15s ease;
}
.btn:active{ transform: translateY(1px); }
.btn-primary{ background: var(--wine); color:#fff; }
.btn-primary:hover{ background: var(--wine-dark); }
.btn-brass{ background: var(--brass); color: var(--ink); }
.btn-brass:hover{ background: var(--brass-light); }
.btn-ghost{ background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover{ background: var(--bg-alt); }
.btn-danger{ background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover{ background: var(--danger-bg); }
.btn-sm{ padding: 6px 12px; font-size:12.5px; }
.btn:disabled{ opacity:.45; cursor:not-allowed; }

/* ---------- Cards / stats ---------- */
.grid-stats{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 26px;
}
.stat-card{
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-card .label{ font-size: 12px; text-transform:uppercase; letter-spacing:.06em; color: var(--ink-soft); margin-bottom:8px; }
.stat-card .value{ font-family: var(--font-display); font-size: 27px; font-weight:600; }
.stat-card .sub{ font-size: 12px; color: var(--ink-soft); margin-top:4px; }
.stat-card.accent{ border-color: var(--wine); }
.stat-card.accent .value{ color: var(--wine); }
.stat-card.alert{ border-color: var(--danger); background: var(--danger-bg); }
.stat-card.alert .value{ color: var(--danger); }

.panel{
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}
.panel-head{
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom: 14px;
}
.panel-head h3{ font-size: 16.5px; }

/* ---------- Luggage-tag badge (signature element) ---------- */
.tag-badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding: 3px 10px 3px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-radius: 3px;
  position: relative;
  border: 1px dashed currentColor;
}
.tag-badge::before{
  content:"";
  width:6px; height:6px;
  border-radius:50%;
  background: var(--paper);
  border: 1.5px solid currentColor;
}
.tag-ok{ color: var(--success); background: var(--success-bg); }
.tag-low{ color: var(--warning); background: var(--warning-bg); }
.tag-out{ color: var(--danger); background: var(--danger-bg); }
.tag-cat{ color: var(--wine); background: #F1E4E8; border-style: solid; }

/* ---------- Tables ---------- */
.table-wrap{ overflow-x:auto; }
table{ width:100%; border-collapse: collapse; font-size: 13.5px; }
thead th{
  text-align:left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-soft);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td{
  padding: 11px 12px;
  border-bottom: 1px solid var(--bg-alt);
  vertical-align: middle;
}
tbody tr:hover{ background: var(--bg-alt); }
tbody tr.row-out{ background: var(--danger-bg); }
tbody tr.row-out:hover{ background: #f0d3ca; }
td.num, th.num{ font-family: var(--font-mono); text-align:right; }
.row-actions{ display:flex; gap:6px; justify-content:flex-end; }
.empty-row td{ text-align:center; padding: 34px 0; color: var(--ink-soft); font-style: italic; }

/* ---------- Forms ---------- */
.field{ margin-bottom: 14px; }
.field label{
  display:block; font-size: 12px; font-weight:600;
  color: var(--ink-soft); margin-bottom:5px; text-transform:uppercase; letter-spacing:.04em;
}
.field input, .field select, .field textarea{
  width:100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--bg);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus{
  outline: none; border-color: var(--wine); background: var(--paper);
}
.field-row{ display:grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hint{ font-size:11.5px; color: var(--ink-soft); margin-top:4px; }

.toolbar{
  display:flex; align-items:center; gap:10px; flex-wrap:wrap;
  margin-bottom: 16px;
}
.search-box{ position:relative; flex:1; min-width: 200px; }
.search-box input{
  width:100%; padding: 9px 12px 9px 32px;
  border:1px solid var(--line); border-radius: var(--radius-s);
  background: var(--paper); font-size:13.5px;
}
.search-box::before{
  content:"⚲"; position:absolute; left:11px; top:50%; transform:translateY(-50%) rotate(90deg);
  color: var(--ink-soft); font-size:13px;
}
select.filter-select{
  padding: 9px 10px; border:1px solid var(--line); border-radius: var(--radius-s);
  background: var(--paper); font-size:13px; color: var(--ink);
}

/* ---------- Modal ---------- */
.modal-overlay{
  position:fixed; inset:0; background: rgba(38,32,28,.45);
  display:none; align-items:center; justify-content:center; z-index:100; padding:20px;
}
.modal-overlay.open{ display:flex; }
.modal{
  background: var(--paper);
  border-radius: var(--radius-m);
  padding: 26px;
  width: 100%; max-width: 460px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
  max-height: 88vh; overflow-y:auto;
}
.modal-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:16px; }
.modal-close{ background:none; border:none; font-size:20px; color: var(--ink-soft); line-height:1; }
.modal-foot{ display:flex; justify-content:flex-end; gap:10px; margin-top: 18px; }

/* ---------- POS / Vente ---------- */
.pos-layout{ display:grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items:flex-start; }
.article-picker{ display:grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.article-card{
  background: var(--paper); border:1px solid var(--line); border-radius: var(--radius-s);
  padding: 13px 14px; text-align:left; display:flex; flex-direction:column; gap:6px;
}
.article-card:hover{ border-color: var(--wine); }
.article-card:disabled{ opacity:.4; cursor:not-allowed; }
.article-card .nm{ font-weight:600; font-size:13.5px; }
.article-card .meta{ display:flex; justify-content:space-between; align-items:center; font-size:12px; color: var(--ink-soft); }
.article-card .px{ font-family: var(--font-mono); color: var(--wine); font-weight:700; }

/* Ticket / receipt styled cart — signature echo */
.ticket{
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 22px 20px;
  position: sticky; top: 20px;
  background-image:
    repeating-linear-gradient(to bottom, transparent 0 8px, var(--bg-alt) 8px 9px);
  background-size: 100% 100%;
}
.ticket-head{ text-align:center; border-bottom:1px dashed var(--line); padding-bottom:12px; margin-bottom:12px; }
.ticket-head .name{ font-family: var(--font-display); font-size:18px; }
.ticket-head .tag{ font-size:10.5px; color: var(--ink-soft); text-transform:uppercase; letter-spacing:.08em; }
.ticket-items{ min-height: 60px; margin-bottom: 12px; }
.ticket-line{ display:flex; justify-content:space-between; align-items:center; gap:8px; padding: 7px 0; border-bottom: 1px dotted var(--line); font-size:13px; }
.ticket-line .l-name{ flex:1; }
.ticket-line .l-qty{ display:flex; align-items:center; gap:5px; }
.qty-btn{ width:20px; height:20px; border:1px solid var(--line); background:var(--paper); border-radius:4px; font-size:12px; line-height:1; }
.ticket-total{ display:flex; justify-content:space-between; align-items:baseline; border-top:1px dashed var(--line); padding-top:12px; margin-top:6px; }
.ticket-total .lbl{ font-size:13px; color: var(--ink-soft); text-transform:uppercase; letter-spacing:.05em; }
.ticket-total .amt{ font-family: var(--font-display); font-size:24px; color: var(--wine); font-weight:700; }
.ticket-empty{ text-align:center; color: var(--ink-soft); font-size:13px; font-style:italic; padding: 20px 0; }

/* ---------- Report cards ---------- */
.report-range-btns{ display:flex; gap:8px; flex-wrap:wrap; }
.report-range-btns .btn.active-range{ background: var(--wine); color:#fff; }
.top-list{ list-style:none; margin:0; padding:0; }
.top-list li{ display:flex; justify-content:space-between; padding:9px 0; border-bottom:1px solid var(--bg-alt); font-size:13.5px; }
.top-list li:last-child{ border-bottom:none; }
.top-list .rank{ color: var(--brass); font-family: var(--font-mono); margin-right:8px; }

/* ---------- Écran de connexion (rôles) ---------- */
.login-card{ max-width: 380px; }
.role-btn{
  display:flex; flex-direction:column; align-items:flex-start; gap:4px;
  width:100%; padding: 15px 18px; text-align:left;
}
.role-btn-title{ font-size: 14.5px; font-weight:700; }
.role-btn .hint{ margin:0; font-size:11.5px; }
.role-btn.btn-primary .hint{ color: rgba(255,255,255,.8); }

/* ---------- Toast ---------- */
#toast{
  position:fixed; bottom:22px; left:50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 8px;
  font-size:13.5px; opacity:0; pointer-events:none; transition: all .25s ease; z-index:200;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
#toast.show{ opacity:1; transform: translateX(-50%) translateY(0); }
#toast.err{ background: var(--danger); }

/* ---------- Mobile nav ---------- */
.mobile-topbar{ display:none; }
@media (max-width: 880px){
  #app{ grid-template-columns: 1fr; }
  .sidebar{ position:fixed; left:0; right:0; bottom:0; top:auto; height:auto; flex-direction:row; z-index:50; border-right:none; border-top:1px solid var(--line); }
  .sidebar .brand, .sidebar-foot{ display:none; }
  .nav{ flex-direction:row; justify-content:space-around; padding:6px; }
  .nav-item{ flex-direction:column; gap:3px; font-size:10.5px; padding:8px 4px; text-align:center; }
  .nav-item .ic{ font-size:18px; }
  main{ padding: 16px 16px 90px; }
  .mobile-topbar{
    display:flex; align-items:center; gap:10px; padding: 14px 4px 18px;
  }
  .grid-stats{ grid-template-columns: 1fr 1fr; }
  .pos-layout{ grid-template-columns: 1fr; }
  .article-picker{ grid-template-columns: 1fr 1fr; }
  .field-row{ grid-template-columns: 1fr; }
  .ticket{ position:static; }
}

/* Print styles for report preview area (screen only app, PDF handled via JS) */
@media print{
  .sidebar, .toolbar, .btn{ display:none !important; }
}
