/* ============================================================
   EXPERT FACT — Design System (shadcn/ui style)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --background:    0 0% 100%;
  --foreground:    222.2 84% 4.9%;
  --card:          0 0% 100%;
  --border:        214.3 31.8% 91.4%;
  --input:         214.3 31.8% 91.4%;
  --primary:       222.2 47.4% 11.2%;
  --primary-fg:    210 40% 98%;
  --secondary:     210 40% 96.1%;
  --secondary-fg:  222.2 47.4% 11.2%;
  --muted:         210 40% 96.1%;
  --muted-fg:      215.4 16.3% 46.9%;
  --accent:        210 40% 96.1%;
  --accent-fg:     222.2 47.4% 11.2%;
  --destructive:   0 84.2% 60.2%;
  --destructive-fg:210 40% 98%;
  --ring:          222.2 84% 4.9%;
  --radius:        0.5rem;
  --success:       142.1 76.2% 36.3%;
  --warning:       45.4 93.4% 47.5%;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }
body { font-family: 'Inter', system-ui, sans-serif; font-size: 14px; line-height: 1.5; background: hsl(var(--background)); color: hsl(var(--foreground)); }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea { font: inherit; }
[x-cloak] { display: none !important; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 3px; }

/* ── Card ───────────────────────────────────────────────────── */
.sh-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
}

/* ── Input ──────────────────────────────────────────────────── */
.sh-input {
  display: flex; width: 100%; height: 36px; padding: 0 12px;
  border: 1px solid hsl(var(--input)); border-radius: var(--radius);
  background: hsl(var(--background)); font-size: 14px;
  transition: border-color 150ms; outline: none;
}
.sh-input:focus { border-color: hsl(var(--ring)); box-shadow: 0 0 0 2px hsla(var(--ring)/.12); }
.sh-input::placeholder { color: hsl(var(--muted-fg)); }

.sh-select {
  display: flex; width: 100%; height: 36px; padding: 0 12px;
  border: 1px solid hsl(var(--input)); border-radius: var(--radius);
  background: hsl(var(--background)); font-size: 14px;
  transition: border-color 150ms; outline: none; cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
.sh-select:focus { border-color: hsl(var(--ring)); }

.sh-textarea {
  display: flex; width: 100%; padding: 8px 12px;
  border: 1px solid hsl(var(--input)); border-radius: var(--radius);
  background: hsl(var(--background)); font-size: 14px; line-height: 1.5;
  transition: border-color 150ms; outline: none; resize: vertical;
}
.sh-textarea:focus { border-color: hsl(var(--ring)); box-shadow: 0 0 0 2px hsla(var(--ring)/.12); }

/* ── Buttons ────────────────────────────────────────────────── */
.sh-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius); font-size: 14px; font-weight: 500;
  transition: all 150ms; white-space: nowrap; padding: 8px 16px; height: 36px;
  outline: none; cursor: pointer; border: 1px solid transparent;
}
.sh-btn:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
.sh-btn:disabled { opacity: .5; pointer-events: none; }

.sh-btn-default { background: hsl(var(--primary)); color: hsl(var(--primary-fg)); }
.sh-btn-default:hover { opacity: .9; }

.sh-btn-outline { border-color: hsl(var(--input)); background: hsl(var(--background)); color: hsl(var(--foreground)); }
.sh-btn-outline:hover { background: hsl(var(--accent)); }

.sh-btn-ghost { background: transparent; color: hsl(var(--foreground)); }
.sh-btn-ghost:hover { background: hsl(var(--accent)); }

.sh-btn-destructive { background: hsl(var(--destructive)); color: hsl(var(--destructive-fg)); }
.sh-btn-destructive:hover { opacity: .9; }
.sh-btn-success       { background: #16a34a; color: #fff; border-color: #16a34a; }
.sh-btn-success:hover { background: #15803d; }

.sh-btn-success { background: hsl(var(--success)); color: #fff; }
.sh-btn-success:hover { opacity: .9; }

.sh-btn-sm { height: 30px; padding: 4px 12px; font-size: 13px; }
.sh-btn-lg { height: 42px; padding: 10px 20px; font-size: 15px; }

/* ── Badge statuts ──────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge-brouillon           { background: hsl(var(--muted));  color: hsl(var(--muted-fg)); }
.badge-envoye              { background: #dbeafe; color: #1d4ed8; }
.badge-envoyee             { background: #dbeafe; color: #1d4ed8; }
.badge-accepte             { background: #dcfce7; color: #15803d; }
.badge-refuse              { background: #fee2e2; color: #dc2626; }
.badge-expire              { background: #fef3c7; color: #b45309; }
.badge-payee               { background: #dcfce7; color: #15803d; }
.badge-partiellement_payee { background: #fed7aa; color: #c2410c; }
.badge-annulee             { background: #f1f5f9; color: #64748b; }
.badge-emis                { background: #dcfce7; color: #15803d; }

/* ── Table ──────────────────────────────────────────────────── */
.sh-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sh-table th { text-align: left; padding: 10px 14px; font-weight: 500; color: hsl(var(--muted-fg)); font-size: 13px; border-bottom: 1px solid hsl(var(--border)); background: hsl(210 40% 98%); }
.sh-table td { padding: 11px 14px; border-bottom: 1px solid hsl(var(--border)); }
.sh-table tbody tr:last-child td { border-bottom: none; }
.sh-table tbody tr:hover { background: hsl(var(--muted) / .4); }

/* ── Label ──────────────────────────────────────────────────── */
.sh-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; color: hsl(var(--foreground)); }
.sh-label.required::after { content: ' *'; color: hsl(var(--destructive)); }

/* ── Flash messages ─────────────────────────────────────────── */
.flash-success { background: #dcfce7; border: 1px solid #bbf7d0; color: #166534; padding: 10px 16px; border-radius: var(--radius); font-size: 14px; }
.flash-error   { background: #fee2e2; border: 1px solid #fecaca; color: #991b1b; padding: 10px 16px; border-radius: var(--radius); font-size: 14px; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 4px; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  font-size: 13px; transition: all 150ms;
}
.pagination a:hover { background: hsl(var(--accent)); }
.pagination .current { background: hsl(var(--primary)); color: hsl(var(--primary-fg)); border-color: hsl(var(--primary)); }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* ── Document preview ───────────────────────────────────────── */
.doc-paper {
  background: #fff;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 3rem;
  max-width: 820px;
  margin: 0 auto;
  box-shadow: 0 1px 8px rgba(0,0,0,.06);
}

/* ── Ligne articles ─────────────────────────────────────────── */
.ligne-row { border-bottom: 1px solid hsl(var(--border)); }
.ligne-row:last-child { border-bottom: none; }

/* ── Signature pad ──────────────────────────────────────────── */
#signature-pad {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  cursor: crosshair;
  touch-action: none;
}

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(2px);
  z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 2rem;
  width: 100%; max-width: 500px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}

/* ── Print ──────────────────────────────────────────────────── */
@media print {
  aside, header, .no-print { display: none !important; }
  body { background: white; }
  .doc-paper { box-shadow: none; border: none; padding: 0; }
}
