/* ═══════════════════════════════════════════════════════════════════════════
   FLAIR ERP v9.0 — Design System "Dark Nebula"
   © 2026 Sébastien Quevillon — Proprietary
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── Custom Properties ─────────────────────────────────────────────────────── */
:root {
  /* Background */
  --bg:         #04040f;
  --bg2:        #07071e;
  --surface:    #0c0c28;
  --surface2:   #111135;

  /* Borders */
  --border:     rgba(108,99,255,.18);
  --border2:    rgba(108,99,255,.38);

  /* Accent palette */
  --violet:     #7c3aed;
  --violet-g:   rgba(124,58,237,.4);
  --cyan:       #06b6d4;
  --cyan-g:     rgba(6,182,212,.35);
  --pink:       #ec4899;
  --pink-g:     rgba(236,72,153,.35);
  --green:      #10b981;
  --green-g:    rgba(16,185,129,.35);
  --amber:      #f59e0b;
  --amber-g:    rgba(245,158,11,.35);
  --red:        #ef4444;
  --red-g:      rgba(239,68,68,.35);
  --indigo:     #6366f1;

  /* Text */
  --t1: #e2e8f0;
  --t2: #94a3b8;
  --t3: #475569;

  /* Layout */
  --sidebar-w: 248px;
  --header-h:  62px;
  --r:  10px;
  --rl: 14px;
  --rx: 20px;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--t1);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ── Three.js Canvas ────────────────────────────────────────────────────────── */
#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .65;
}

/* ── App Layout ─────────────────────────────────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: rgba(7,7,30,.88);
  backdrop-filter: blur(24px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 60;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .brand-name {
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: -.03em;
  background: linear-gradient(120deg, var(--violet), var(--cyan) 60%, var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-brand .brand-sub {
  display: block;
  font-size: .65rem;
  font-weight: 600;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-top: 2px;
}

.nav-section { padding: 14px 10px 4px; }

.nav-section-label {
  font-size: .62rem;
  font-weight: 700;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: .12em;
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--t2);
  font-size: .84rem;
  font-weight: 500;
  transition: all .18s;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  margin-bottom: 2px;
}

.nav-link::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--violet-g), transparent);
  opacity: 0;
  transition: opacity .18s;
}

.nav-link:hover           { color: var(--t1); background: rgba(124,58,237,.08); }
.nav-link:hover::before   { opacity: 1; }
.nav-link.active          { color: #fff; background: rgba(124,58,237,.2); border: 1px solid var(--border2); }
.nav-link.active::before  { opacity: 1; }

.nav-link .ni   { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }
.nav-link .nbadge {
  margin-left: auto;
  background: var(--pink);
  color: #fff;
  font-size: .6rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 10px 18px;
  border-top: 1px solid var(--border);
}

/* ── Page Wrapper ────────────────────────────────────────────────────────────── */
.page {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.header {
  height: var(--header-h);
  background: rgba(4,4,15,.82);
  backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-info {}
.header-title { font-size: 1.05rem; font-weight: 700; }
.header-sub   { font-size: .72rem; color: var(--t2); }

.header-spacer { flex: 1; }

.header-search {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 12px;
  width: 210px;
  transition: border-color .2s, box-shadow .2s;
}
.header-search:focus-within {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--violet-g);
}
.header-search input {
  background: none; border: none; outline: none;
  color: var(--t1); font-size: .83rem; width: 100%; padding: 0;
}

.hbtn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--t2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem;
  transition: all .18s;
  position: relative;
}
.hbtn:hover { border-color: var(--violet); color: var(--t1); box-shadow: 0 0 14px var(--violet-g); }
.hbtn .dot  { position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--pink); }

/* ── Main Content ────────────────────────────────────────────────────────────── */
.main { padding: 24px 28px; flex: 1; }

/* ── Glass Panel ─────────────────────────────────────────────────────────────── */
.glass {
  background: rgba(12,12,40,.75);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  transition: border-color .25s, box-shadow .25s;
}
.glass:hover {
  border-color: rgba(124,58,237,.32);
  box-shadow: 0 0 28px rgba(124,58,237,.08);
}

/* ── KPI Grid ───────────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.kpi {
  padding: 18px 20px 16px;
  position: relative;
  overflow: hidden;
  cursor: default;
  transition: transform .2s, box-shadow .2s;
}
.kpi:hover { transform: translateY(-3px); box-shadow: 0 8px 32px rgba(0,0,0,.35); }

.kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--kpi-top, linear-gradient(90deg, var(--violet), var(--cyan)));
}
.kpi::after {
  content: '';
  position: absolute;
  top: -50px; right: -50px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: var(--kpi-glow, var(--violet-g));
  filter: blur(35px);
  opacity: .55;
  pointer-events: none;
}

.kpi-icon  { font-size: 1.45rem; margin-bottom: 10px; }
.kpi-val   {
  font-size: 2rem; font-weight: 900; line-height: 1; margin-bottom: 4px;
  background: var(--kpi-top, linear-gradient(135deg, var(--violet), var(--cyan)));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.kpi-lbl   { font-size: .74rem; color: var(--t2); font-weight: 500; }
.kpi-trend { font-size: .7rem; color: var(--green); margin-top: 6px; }

/* ── Section Header ──────────────────────────────────────────────────────────── */
.sh {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.sh-title { font-size: .9rem; font-weight: 700; white-space: nowrap; }
.sh-line  { flex: 1; height: 1px; background: linear-gradient(90deg, var(--border), transparent); }

/* ── Toolbar ─────────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 9px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: center;
}
.spacer { flex: 1; }

/* ── Inputs ──────────────────────────────────────────────────────────────────── */
input, select, textarea {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 11px;
  color: var(--t1);
  font-size: .83rem;
  font-family: inherit;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(124,58,237,.15);
}
select option { background: var(--surface2); }

/* ── Buttons ──────────────────────────────────────────────────────────────────── */
.btn {
  padding: 7px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: .83rem;
  font-weight: 600;
  font-family: inherit;
  transition: all .18s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn::after { content:''; position:absolute; inset:0; background:rgba(255,255,255,.1); opacity:0; transition:opacity .18s; }
.btn:hover::after  { opacity: 1; }
.btn:active        { transform: scale(.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--violet) 0%, #9333ea 100%);
  color: #fff;
  box-shadow: 0 3px 16px var(--violet-g);
}
.btn-primary:hover { box-shadow: 0 4px 24px rgba(124,58,237,.6); transform: translateY(-1px); }

.btn-cyan    { background: linear-gradient(135deg, var(--cyan), #0284c7); color:#fff; box-shadow: 0 3px 16px var(--cyan-g); }
.btn-success { background: linear-gradient(135deg, var(--green), #059669); color:#fff; box-shadow: 0 3px 16px var(--green-g); }
.btn-warn    { background: linear-gradient(135deg, var(--amber), #d97706); color:#000; }
.btn-danger  { background: linear-gradient(135deg, var(--red), #dc2626); color:#fff; box-shadow: 0 3px 16px var(--red-g); }
.btn-ghost   { background: rgba(255,255,255,.05); border: 1px solid var(--border); color: var(--t2); }
.btn-ghost:hover { color: var(--t1); border-color: var(--violet); }

.btn-sm   { padding: 4px 11px; font-size: .76rem; border-radius: 6px; }
.btn-icon { padding: 7px; border-radius: 8px; }

/* ── Tab Bar ────────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 3px;
  padding: 4px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 11px;
  margin-bottom: 18px;
  width: fit-content;
}

.tab-btn {
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: .81rem;
  font-weight: 600;
  color: var(--t2);
  transition: all .18s;
  border: none;
  background: none;
  font-family: inherit;
  white-space: nowrap;
}
.tab-btn:hover  { color: var(--t1); background: rgba(255,255,255,.06); }
.tab-btn.active {
  background: linear-gradient(135deg, var(--violet), #9333ea);
  color: #fff;
  box-shadow: 0 2px 12px var(--violet-g);
}

.tab-pane         { display: none; }
.tab-pane.active  { display: block; animation: fadeUp .22s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Table ──────────────────────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .83rem; }

th {
  background: rgba(124,58,237,.09);
  color: var(--t2);
  padding: 10px 13px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: .71rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  white-space: nowrap;
}

td {
  padding: 10px 13px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  transition: background .12s;
}
tr:last-child td { border-bottom: none; }
tr:hover td     { background: rgba(124,58,237,.05); }

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: .69rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge::before { content:''; width:5px; height:5px; border-radius:50%; background:currentColor; }

.badge-active     { background:rgba(16,185,129,.14);  color:#10b981; border:1px solid rgba(16,185,129,.28); }
.badge-on_leave   { background:rgba(245,158,11,.14);  color:#f59e0b; border:1px solid rgba(245,158,11,.28); }
.badge-terminated,.badge-rejected { background:rgba(239,68,68,.14); color:#ef4444; border:1px solid rgba(239,68,68,.28); }
.badge-pending    { background:rgba(245,158,11,.14);  color:#f59e0b; border:1px solid rgba(245,158,11,.28); }
.badge-approved   { background:rgba(16,185,129,.14);  color:#10b981; border:1px solid rgba(16,185,129,.28); }
.badge-cancelled  { background:rgba(100,116,139,.14); color:#64748b; border:1px solid rgba(100,116,139,.28); }
.badge-draft      { background:rgba(100,116,139,.14); color:#64748b; border:1px solid rgba(100,116,139,.28); }
.badge-validated  { background:rgba(124,58,237,.14);  color:#7c3aed; border:1px solid rgba(124,58,237,.28); }
.badge-paid,.badge-delivered { background:rgba(16,185,129,.14); color:#10b981; border:1px solid rgba(16,185,129,.28); }
.badge-submitted,.badge-sent { background:rgba(6,182,212,.14);  color:#06b6d4; border:1px solid rgba(6,182,212,.28); }
.badge-online,.badge-won     { background:rgba(16,185,129,.14); color:#10b981; border:1px solid rgba(16,185,129,.28); }
.badge-offline    { background:rgba(100,116,139,.14); color:#64748b; border:1px solid rgba(100,116,139,.28); }
.badge-recording  { background:rgba(239,68,68,.14);   color:#ef4444; border:1px solid rgba(239,68,68,.28); animation: pulse-badge 1.5s infinite; }
.badge-overdue    { background:rgba(239,68,68,.14);   color:#ef4444; border:1px solid rgba(239,68,68,.28); }
.badge-new,.badge-prospect { background:rgba(6,182,212,.14); color:#06b6d4; border:1px solid rgba(6,182,212,.28); }

@keyframes pulse-badge { 0%,100%{opacity:1} 50%{opacity:.55} }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-bg {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(5px);
  z-index: 200;
  align-items: center; justify-content: center;
}
.modal-bg.open { display: flex; }

.modal {
  background: rgba(12,12,40,.97);
  backdrop-filter: blur(28px);
  border: 1px solid rgba(124,58,237,.38);
  border-radius: var(--rx);
  padding: 28px 30px;
  width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 30px 60px rgba(0,0,0,.55), 0 0 70px rgba(124,58,237,.12);
  animation: modalIn .28s cubic-bezier(.34,1.56,.64,1);
}

@keyframes modalIn {
  from { opacity:0; transform:scale(.9) translateY(18px); }
  to   { opacity:1; transform:scale(1)  translateY(0); }
}

.modal-hd {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 22px;
}
.modal-hd-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: rgba(124,58,237,.18);
  border: 1px solid rgba(124,58,237,.38);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}
.modal-hd h3     { font-size: 1rem; font-weight: 700; }
.modal-hd-sub    { font-size: .73rem; color: var(--t2); }
.modal-close     { margin-left: auto; }

.form-grid       { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid.one   { grid-template-columns: 1fr; }
.field           { display: flex; flex-direction: column; gap: 5px; }
.field.full      { grid-column: 1 / -1; }
.field label     { font-size: .72rem; color: var(--t2); font-weight: 600; }

.modal-ft {
  display: flex; gap: 9px; justify-content: flex-end;
  margin-top: 22px; padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Pagination ──────────────────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
  font-size: .79rem; color: var(--t2);
}
.pagination span { padding: 0 10px; }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.toast-box {
  position: fixed; top: 20px; right: 20px;
  z-index: 400;
  display: flex; flex-direction: column; gap: 7px;
  pointer-events: none;
}

.toast {
  background: rgba(12,12,40,.97);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 16px;
  display: flex; align-items: center; gap: 9px;
  font-size: .83rem;
  min-width: 240px;
  max-width: 320px;
  box-shadow: 0 8px 28px rgba(0,0,0,.4);
  animation: toastIn .28s ease;
  pointer-events: auto;
}
.toast.success { border-color: rgba(16,185,129,.4); }
.toast.error   { border-color: rgba(239,68,68,.4); }
.toast.info    { border-color: rgba(6,182,212,.4); }
.toast.warn    { border-color: rgba(245,158,11,.4); }
.toast-icon    { font-size: .95rem; flex-shrink: 0; }

@keyframes toastIn  { from{opacity:0;transform:translateX(24px)} to{opacity:1;transform:translateX(0)} }
@keyframes toastOut { to  {opacity:0;transform:translateX(24px)} }

/* ── Empty State ─────────────────────────────────────────────────────────────── */
.empty {
  text-align: center; padding: 44px 20px; color: var(--t2);
}
.empty .ei { font-size: 2.2rem; margin-bottom: 10px; opacity: .45; }
.empty .et { font-size: .9rem; font-weight: 600; margin-bottom: 5px; }
.empty .es { font-size: .78rem; }

/* ── Skeleton ────────────────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,.04) 25%, rgba(255,255,255,.09) 50%, rgba(255,255,255,.04) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0%{background-position:-200% 0} 100%{background-position:200% 0} }

/* ── AI Result Box ───────────────────────────────────────────────────────────── */
.ai-box {
  background: rgba(124,58,237,.07);
  border: 1px solid rgba(124,58,237,.22);
  border-radius: var(--r);
  padding: 16px;
  font-size: .83rem;
  line-height: 1.75;
  white-space: pre-wrap;
  min-height: 90px;
  position: relative;
}
.ai-box::before {
  content: '✦ IA';
  position: absolute; top: -10px; left: 14px;
  background: var(--violet); color: #fff;
  font-size: .62rem; font-weight: 800;
  padding: 2px 8px; border-radius: 4px;
  letter-spacing: .06em;
}

/* ── Divider ─────────────────────────────────────────────────────────────────── */
.divider { height:1px; background:linear-gradient(90deg,transparent,var(--border),transparent); margin:18px 0; }

/* ── Scrollbar ───────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width:4px; height:4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(124,58,237,.4); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(124,58,237,.65); }

/* ── Utility ─────────────────────────────────────────────────────────────────── */
.fw7  { font-weight: 700; }
.fw9  { font-weight: 900; }
.tc   { text-align: center; }
.muted{ color: var(--t2); }
.small{ font-size: .78rem; }
.green{ color: var(--green); }
.red  { color: var(--red); }
.amber{ color: var(--amber); }
.cyan { color: var(--cyan); }
.violet { color: var(--violet); }

.grad-text {
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
