/* =========================================================================
   SuperSpool — Backoffice — Design system (thème sombre raffiné)
   ========================================================================= */

:root {
  /* Fonds */
  --bg:          #0b0e16;
  --bg-2:        #0f1320;
  --surface:     #161b26;
  --surface-2:   #1e222b;   /* aligné sur les styles inline existants */
  --surface-3:   #232a37;
  --elevated:    #1b2130;

  /* Bordures */
  --border:      #263042;
  --border-2:    #313d53;   /* aligné sur l'existant */
  --border-soft: #1c2432;

  /* Marque / accents */
  --primary:     #3b6fe0;
  --primary-600: #315fce;
  --primary-700: #1d3d7c;   /* aligné sur les boutons inline existants */
  --primary-050: rgba(59,111,224,.14);
  --accent:      #2eccb2;

  /* Texte */
  --text:        #e7eaf0;
  --text-dim:    #a0a6b3;
  --text-faint:  #7c8494;

  /* États */
  --success:     #2ecc71;
  --success-bg:  rgba(46,204,113,.12);
  --warning:     #f0b429;
  --warning-bg:  rgba(240,180,41,.12);
  --danger:      #ea525e;
  --danger-bg:   rgba(234,82,94,.12);
  --danger-solid:#7c1d1d;

  /* Formes */
  --radius:      14px;
  --radius-sm:   9px;
  --radius-xs:   6px;
  --shadow:      0 10px 30px rgba(0,0,0,.35);
  --shadow-sm:   0 2px 10px rgba(0,0,0,.25);
  --ring:        0 0 0 3px var(--primary-050);

  --sidebar-w:   256px;
  --topbar-h:    64px;
}

/* ------------------------------------------------------------------ Base */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(59,111,224,.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(46,204,178,.06), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

::selection { background: var(--primary-050); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 20px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #3d4a63; background-clip: content-box; }

/* ================================================================== SHELL */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ------------------------------------------------------------- Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(22,27,38,.95), rgba(13,16,24,.98));
  border-right: 1px solid var(--border-soft);
  padding: 18px 14px;
  gap: 6px;
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 16px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}
.sidebar-brand img { height: 34px; width: auto; display: block; }

.nav-group-label {
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 14px 12px 6px;
}

.sidebar nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
  user-select: none;
}
.nav-item i { width: 18px; text-align: center; font-size: 15px; color: var(--text-faint); transition: color .15s; }
.nav-item:hover { background: rgba(255,255,255,.03); color: var(--text); }
.nav-item:hover i { color: var(--text-dim); }
.nav-item.active {
  background: linear-gradient(90deg, var(--primary-050), rgba(59,111,224,.04));
  color: #fff;
  border-color: rgba(59,111,224,.35);
}
.nav-item.active i { color: var(--primary); }

.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; color: var(--text-dim); font-size: 12.5px; }
.sidebar-user .avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  font-size: 12px;
}
.sidebar-user .u-mail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------- Content */
.content-area { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 26px;
  background: rgba(11,14,22,.72);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
  z-index: 20;
}
.topbar .page-title { font-size: 18px; font-weight: 600; color: var(--text); margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn-icon {
  height: 38px; width: 38px; display: grid; place-items: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-dim); cursor: pointer;
  transition: all .15s;
}
.btn-icon:hover { color: var(--text); border-color: var(--border-2); background: var(--surface-3); }

.content { padding: 26px; min-width: 0; }
.dynamic-content { width: 100%; }
.dynamic-content > h1 {
  font-weight: 600;
  font-size: 24px;
  margin: 0 0 20px;
  letter-spacing: -.01em;
  color: var(--text);
}

/* Fallback pour anciens sélecteurs (compat) */
.header { display: none; }
.body { display: block; }
.menu { width: auto; height: auto; }

/* ================================================================== LOGIN */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 32px 30px;
  animation: cardIn .4s cubic-bezier(.2,.7,.3,1);
}
@keyframes cardIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.login-logo { display: flex; justify-content: center; margin-bottom: 18px; }
.login-logo img { height: 46px; }
.login-title { text-align: center; font-size: 20px; font-weight: 600; margin: 0 0 4px; }
.login-sub { text-align: center; color: var(--text-dim); font-size: 13px; margin: 0 0 26px; }

.login-area { width: 100%; }
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 500;
  color: var(--text-dim); margin-bottom: 7px;
}
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > i {
  position: absolute; left: 14px; color: var(--text-faint); font-size: 14px; pointer-events: none;
}
.input-wrap input { padding-left: 40px !important; }

.login-area input {
  width: 100%;
  padding: 13px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  outline: none;
  color: #fff;
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.login-area input:focus { border-color: var(--primary); box-shadow: var(--ring); }

.login-error {
  display: none;
  align-items: center;
  gap: 8px;
  background: var(--danger-bg);
  border: 1px solid rgba(234,82,94,.35);
  color: #ffb3b8;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}
.login-error.show { display: flex; }

.login-area button, .btn-primary {
  width: 100%;
  padding: 13px 16px;
  background: linear-gradient(180deg, var(--primary), var(--primary-600));
  border: 0;
  border-radius: var(--radius-sm);
  outline: none;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s, transform .05s, box-shadow .15s;
  box-shadow: 0 6px 18px rgba(49,95,206,.25);
}
.login-area button:hover, .btn-primary:hover { filter: brightness(1.08); }
.login-area button:active { transform: translateY(1px); }
.login-area button[disabled] { opacity: .7; cursor: wait; }

/* ================================================================== CARDS */
.stats-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  width: 100%;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  overflow: hidden;
}
.stats-card-column { padding: 20px 22px; min-width: 0; }
/* Séparateurs verticaux discrets entre colonnes KPI */
.stats-card > .stats-card-column + .stats-card-column { border-left: 1px solid var(--border-soft); }
.stats-card > .stats-card-column[style*="border-right"] { border-right-color: var(--border-soft) !important; }
.stats-card > .stats-card-column[style*="border-right"] + .stats-card-column { border-left: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  margin-bottom: 20px;
}

h1 { font-weight: 600; margin: 0 0 18px; font-size: 24px; }
h2 { font-weight: 600; font-size: 17px; margin: 0 0 4px; color: var(--text); }

/* Titre de section standard */
.section-title { color: var(--text-dim); margin-bottom: 10px; font-size: 13px; }

/* ------------------------------------------------------- Bricks / plugins */
.plugin-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--primary-700);
  border-radius: var(--radius);
  width: 200px;
  height: 200px;
  margin: 0 20px 20px 0;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: transform .12s, border-color .15s, background .15s;
}
.plugin-card:hover { transform: translateY(-3px); border-color: var(--primary); background: var(--surface-3); }
.plugin-card-icon { height: 110px; }
.plugin-card-title { margin-top: 12px; font-weight: 600; }

/* ================================================================= TABLES */
table.main-tab {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
table.main-tab thead tr.header-presentation td,
table.main-tab tr.header-presentation td {
  font-weight: 600;
  color: var(--text-faint);
  font-size: 11.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-2);
  white-space: nowrap;
}
table.main-tab tr.line-presentation td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
table.main-tab tr.line-presentation { transition: background .12s; }
table.main-tab tbody tr.line-presentation:hover { background: rgba(255,255,255,.025); }
table.main-tab tbody tr.line-presentation:last-child td { border-bottom: 0; }

/* =========================================================== FORM CONTROLS
   Poli global : arrondit / anime tous les champs, même ceux à style inline
   (l'inline ne fixe que background/border/color/padding). */
input[type="text"], input[type="password"], input[type="number"],
input[type="email"], input[type="search"], select, textarea {
  border-radius: var(--radius-xs);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s, background .15s;
  outline: none;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus,
input[type="email"]:focus, input[type="search"]:focus, select:focus, textarea:focus {
  border-color: var(--primary) !important;
  box-shadow: var(--ring);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
select { cursor: pointer; }
textarea { line-height: 1.5; }

input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px; height: 16px;
  cursor: pointer;
  vertical-align: middle;
}

button {
  font-family: inherit;
  font-weight: 500;
  border-radius: var(--radius-xs);
  transition: filter .15s, box-shadow .15s, transform .05s, background .15s, border-color .15s;
}
button:hover { filter: brightness(1.1); }
button:active { transform: translateY(1px); }
button[disabled] { opacity: .55; cursor: not-allowed; filter: none; }

/* Boutons utilitaires (classes optionnelles) */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-2); background: var(--surface-2);
  color: var(--text); cursor: pointer; font-weight: 500; font-size: 13.5px;
}
.btn:hover { background: var(--surface-3); border-color: #3a465e; }
.btn-accent { background: linear-gradient(180deg, var(--primary), var(--primary-600)); border: 0; color: #fff; box-shadow: 0 4px 14px rgba(49,95,206,.25); }
.btn-danger { background: var(--danger-solid); border: 0; color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }

/* ================================================================= BADGES */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.6;
}
.badge-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.badge-success { background: var(--success-bg); color: #6ee7a8; }
.badge-danger  { background: var(--danger-bg);  color: #ffb3b8; }
.badge-warning { background: var(--warning-bg); color: #f5cd6a; }
.badge-neutral { background: rgba(160,166,179,.12); color: var(--text-dim); }

/* ================================================== SEGMENTED / TABS (sub) */
.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}
.seg button, .seg .seg-item {
  border: 0; background: transparent; color: var(--text-dim);
  padding: 7px 16px; border-radius: var(--radius-xs); cursor: pointer;
  font-weight: 500; font-size: 13.5px; display: inline-flex; align-items: center; gap: 8px;
}
.seg .seg-item:hover { color: var(--text); }
.seg .seg-item.active { background: var(--primary-700); color: #fff; box-shadow: var(--shadow-sm); }

/* ====================================================== SHOP WORKSPACE (ws) */
.ws { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }

.ws-aside {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  position: sticky; top: calc(var(--topbar-h) + 14px);
}
.ws-aside-head { padding: 14px 16px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ws-aside-head .t { font-weight: 600; }
.ws-search { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); }
.ws-search input { width: 100%; padding: 9px 12px 9px 34px; background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text); }
.ws-search .input-wrap > i { left: 12px; }
.ws-list { max-height: calc(100vh - 260px); overflow: auto; }

.shop-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .12s, border-color .12s;
}
.shop-item:hover { background: rgba(255,255,255,.03); }
.shop-item.active { background: var(--primary-050); border-left-color: var(--primary); }
.shop-item .s-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.shop-item .s-ref { color: var(--text-dim); font-size: 12px; margin-top: 2px; }

.ws-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  min-height: 400px;
}
.ws-main-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid var(--border-soft);
}
.ws-main-head .h-title { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.ws-body { padding: 20px; }
.ws-empty { padding: 60px 20px; text-align: center; color: var(--text-dim); }
.ws-empty i { font-size: 34px; color: var(--text-faint); margin-bottom: 14px; display: block; }

/* Grille de champs (édition licence, création format) */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px 18px; }
.form-grid .field-full { grid-column: 1 / -1; }
.form-field label { display: block; font-size: 12px; font-weight: 500; color: var(--text-dim); margin-bottom: 6px; }
.form-field input[type="text"], .form-field input[type="number"], .form-field select {
  width: 100%; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text);
}
.form-actions { display: flex; gap: 10px; margin-top: 20px; align-items: center; }
.form-toggle { display: flex; align-items: center; gap: 10px; }
.form-toggle label { margin: 0; }

/* ================================================================= TOASTS */
#toast-wrap { position: fixed; right: 20px; bottom: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 240px; max-width: 360px;
  background: var(--elevated); border: 1px solid var(--border-2);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 12px 14px; color: var(--text); font-size: 13.5px;
  display: flex; align-items: center; gap: 10px;
  animation: toastIn .25s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast i { font-size: 15px; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ================================================================== MODAL */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(6,8,13,.66); backdrop-filter: blur(3px);
  z-index: 9998; display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  width: 100%; max-width: 460px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; animation: cardIn .25s ease;
}
.modal h3 { margin: 0 0 6px; font-size: 17px; }
.modal p { color: var(--text-dim); margin: 0 0 18px; font-size: 13.5px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ============================================================== UTILITIES */
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.pill-kpi { font-size: 42px; font-weight: 700; margin-bottom: 4px; letter-spacing: -.02em; }

/* Spinner (conservé de l'existant) */
.ico-spin::before {
  content: ''; display: inline-block; width: 14px; height: 14px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn-zip .fa-download, .btn-zip .fa-spinner { font-size: 14px; }
.btn-zip[disabled] { opacity: .7; cursor: wait; }

/* Petit loader inline */
.loading-inline { display: inline-flex; align-items: center; gap: 8px; color: var(--text-dim); padding: 10px 0; }
.loading-inline .ico-spin::before { border-color: var(--text-dim); border-top-color: transparent; }

/* ============================================================ RESPONSIVE */
@media (max-width: 1080px) {
  .ws { grid-template-columns: 1fr; }
  .ws-aside { position: static; }
  .ws-list { max-height: 320px; }
}
@media (max-width: 860px) {
  :root { --sidebar-w: 68px; }
  .sidebar { padding: 16px 10px; }
  .sidebar-brand .brand-text, .nav-item span, .nav-group-label, .sidebar-user .u-mail { display: none; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .form-grid { grid-template-columns: 1fr; }
}
