/* ============================================================================
   LegiTag ADMIN -- feuille de style de la console interne
   ----------------------------------------------------------------------------
   Identite visuelle VOLONTAIREMENT distincte de la plateforme client :
   fond ardoise, barre laterale sombre, accent indigo. Un administrateur doit
   voir en un coup d'oeil qu'il est dans l'outil qui gere la facturation et
   les donnees de TOUS les clients -- pas dans le compte d'un client.

   Les couleurs de STATUT (vert / ambre / corail / violet) restent celles du
   projet : un badge "suspendu" doit se lire pareil partout.
============================================================================ */

:root {
  --bg:          #eef1f6;
  --surface:     #ffffff;
  --surface-2:   #f7f9fc;
  --border:      #dfe4ec;
  --border-2:    #c8d0dd;
  --text:        #16202e;
  --text-2:      #465468;
  --text-3:      #7a869a;

  --accent:      #4f46e5;     /* indigo : l'outil interne */
  --accent-hover:#4338ca;
  --accent-soft: #eef0fe;
  --accent-ring: rgba(79, 70, 229, .16);

  --nav-bg:      #16202e;
  --nav-text:    #9fb0c6;
  --nav-active:  #ffffff;

  /* Statuts : identiques a la plateforme client (coherence de lecture) */
  --success-soft:#f0faf3; --success-text:#3f7f56; --success-border:#c5e8cf;
  --warn-soft:   #fdf8e6; --warn-text:   #916a15; --warn-border:   #f7e59d;
  --danger-soft: #fdefec; --danger-text: #a54a3c; --danger-border: #f4bfb3;
  --info-soft:   #eaf2fa; --info-text:   #1a3f9c; --info-border:   #8ebce8;
  --draft-soft:  #f4f5f7; --draft-text:  #354255; --draft-border:  #d3d5de;

  --radius:   12px;
  --radius-sm:9px;
  --sh-xs: 0 1px 2px rgba(16,32,46,.05);
  --sh-sm: 0 2px 8px rgba(16,32,46,.07);
  --sh-md: 0 8px 28px rgba(16,32,46,.12);
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
        Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- Sidebar */

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--nav-bg); color: var(--nav-text);
  display: flex; flex-direction: column; padding: 18px 12px; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; }
.brand i { width: 22px; height: 22px; color: #a5b4fc; }
.brand strong { display: block; color: #fff; font-size: 15px; letter-spacing: -.01em; }
.brand span { display: block; font-size: 11px; color: #6b7c94; letter-spacing: .04em;
              text-transform: uppercase; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: var(--radius-sm); color: var(--nav-text); font-size: 13.5px;
  font-weight: 500; text-decoration: none; transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--accent); color: var(--nav-active); }
.nav-item i { width: 17px; height: 17px; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.09); padding-top: 12px; }
.who { display: flex; align-items: center; gap: 8px; padding: 4px 12px 10px;
       font-size: 12.5px; color: #8496ad; }
.who i { width: 15px; height: 15px; flex: none; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .btn { width: 100%; justify-content: flex-start; color: #9fb0c6; }
.sidebar-foot .btn:hover { background: rgba(255,255,255,.06); color: #fff; }

/* ------------------------------------------------------------------ Layout */

.main { margin-left: var(--sidebar-w); padding: 30px 34px 70px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between;
             gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
h1 { font-size: 23px; font-weight: 650; margin: 0 0 4px; letter-spacing: -.02em; }
.page-sub { color: var(--text-3); font-size: 13.5px; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -.01em; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--sh-xs);
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between;
             gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.card-desc { color: var(--text-3); font-size: 13px; margin: 4px 0 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1080px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 860px) {
  .sidebar { position: static; width: auto; flex-direction: row; align-items: center;
             padding: 10px; overflow-x: auto; }
  .sidebar nav { flex-direction: row; }
  .sidebar-foot { border: 0; padding: 0 0 0 10px; display: flex; gap: 8px; }
  .who { display: none; }
  .main { margin-left: 0; padding: 20px 16px 60px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------- Stats */

.stat { background: var(--surface); border: 1px solid var(--border);
        border-radius: var(--radius); padding: 16px 18px; }
.stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
              color: var(--text-3); font-weight: 600; }
.stat-value { font-size: 27px; font-weight: 650; margin-top: 6px; letter-spacing: -.02em;
              font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }

/* ------------------------------------------------------------------ Tables */

.table-wrap { overflow-x: auto; border: 1px solid var(--border);
              border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; padding: 11px 14px; background: var(--surface-2);
     color: var(--text-2); font-weight: 600; font-size: 12px;
     border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-link { color: var(--text); font-weight: 600; }
.row-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }

/* ------------------------------------------------------------------ Badges */

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
         border-radius: 20px; font-size: 11.5px; font-weight: 600;
         border: 1px solid transparent; white-space: nowrap; }
.badge-success { background: var(--success-soft); color: var(--success-text); border-color: var(--success-border); }
.badge-warn    { background: var(--warn-soft);    color: var(--warn-text);    border-color: var(--warn-border); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger-text);  border-color: var(--danger-border); }
.badge-info    { background: var(--info-soft);    color: var(--info-text);    border-color: var(--info-border); }
.badge-draft   { background: var(--draft-soft);   color: var(--draft-text);   border-color: var(--draft-border); }
.badge-accent  { background: var(--accent-soft);  color: var(--accent);       border-color: #d7d9fb; }

/* ----------------------------------------------------------------- Buttons */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px;
       height: 38px; padding: 0 15px; border-radius: var(--radius-sm);
       border: 1px solid transparent; background: none; font-size: 13.5px;
       font-weight: 550; cursor: pointer; font-family: inherit;
       transition: background .12s, border-color .12s, color .12s; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn i, .btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text);
                 border-color: var(--border-2); box-shadow: var(--sh-xs); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger-text); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #8e3d31; }
.btn-sm { height: 31px; padding: 0 11px; font-size: 12.5px; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------- Forms */

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2);
        margin: 0 0 6px; }
.input, input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], select, textarea {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--border-2);
  border-radius: var(--radius-sm); background: #fff; font-size: 13.5px;
  font-family: inherit; color: var(--text);
}
textarea { height: auto; padding: 9px 11px; resize: vertical; min-height: 74px; }
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.field { margin-bottom: 14px; }
.field-hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.field-error { font-size: 12px; color: var(--danger-text); margin-top: 5px; }
.input.err, input.err { border-color: var(--danger-border); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius);
           padding: 16px; margin: 0 0 18px; }
legend { font-size: 11.5px; font-weight: 700; text-transform: uppercase;
         letter-spacing: .05em; color: var(--text-3); padding: 0 7px; }
.check { display: flex; align-items: flex-start; gap: 9px; padding: 9px 11px;
         border: 1px solid var(--border); border-radius: var(--radius-sm);
         cursor: pointer; margin-bottom: 8px; background: #fff; }
.check:hover { border-color: var(--border-2); background: var(--surface-2); }
.check input { width: auto; height: auto; margin-top: 2px; accent-color: var(--accent); }
.check-body strong { display: block; font-size: 13.5px; font-weight: 600; }
.check-body span { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 1px; }

/* ------------------------------------------------------------------ States */

.empty { text-align: center; padding: 46px 20px; color: var(--text-3); }
.empty i { width: 34px; height: 34px; color: var(--border-2); margin-bottom: 10px; }
.empty p { margin: 0 0 4px; font-weight: 600; color: var(--text-2); }
.empty span { font-size: 13px; }
.skeleton { background: linear-gradient(90deg, #eef1f6 25%, #e3e8f0 50%, #eef1f6 75%);
            background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: 6px;
            height: 13px; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ------------------------------------------------------------------ Toasts */

.toast-host { position: fixed; right: 18px; bottom: 18px; display: flex;
              flex-direction: column; gap: 8px; z-index: 90; }
.toast { background: var(--nav-bg); color: #fff; padding: 11px 16px;
         border-radius: var(--radius-sm); font-size: 13.5px; box-shadow: var(--sh-md);
         max-width: 380px; animation: toastIn .18s ease-out; }
.toast-success { background: var(--success-text); }
.toast-error   { background: var(--danger-text); }
.toast.out { opacity: 0; transform: translateY(6px); transition: .25s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------------ Modals */

.modal-backdrop { position: fixed; inset: 0; background: rgba(16,32,46,.45);
                  display: flex; align-items: center; justify-content: center;
                  z-index: 80; padding: 20px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #fff; border-radius: var(--radius); padding: 22px;
         width: 100%; max-width: 460px; box-shadow: var(--sh-md); }
.modal h3 { margin: 0 0 8px; font-size: 16.5px; font-weight: 650; }
.modal p { margin: 0 0 16px; color: var(--text-2); font-size: 13.5px; line-height: 1.55; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }

/* ------------------------------------------------------------- Login page */

.login-wrap { min-height: 100vh; display: flex; align-items: center;
              justify-content: center; padding: 24px; background: var(--nav-bg); }
.login-card { background: #fff; border-radius: 16px; padding: 34px;
              width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.28); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.login-brand i { width: 26px; height: 26px; color: var(--accent); }
.login-brand strong { font-size: 18px; letter-spacing: -.02em; }
.login-sub { color: var(--text-3); font-size: 13.5px; margin: 0 0 22px; }

/* --------------------------------------------------------------- Utilities */

.muted { color: var(--text-3); }
.mono  { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.nowrap{ white-space: nowrap; }
.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.flex  { display: flex; align-items: center; gap: 9px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap  { flex-wrap: wrap; }
.right { margin-left: auto; }
