/* ============================================================
   GESTIVA · DESIGN SYSTEM v2  — global.css
   Toutes les variables + composants partagés.
   ============================================================ */

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

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  /* Couleurs primaires */
  --primary:        #2563eb;
  --primary-hover:  #1d4ed8;
  --primary-light:  #eff6ff;
  --primary-border: #bfdbfe;
  --primary-text:   #1e40af;

  /* Accent secondaire */
  --secondary:      #0f172a;
  --secondary-hover:#1e293b;
  --secondary-light:#f8fafc;

  /* Sidebar */
  --sidebar-w:        240px;
  --sidebar-collapsed-w: 72px;
  --sidebar-bg:       #0b1426;
  --sidebar-hover:    rgba(255,255,255,0.06);
  --sidebar-active:   #2563eb;
  --sidebar-text:     #8898b3;
  --sidebar-txt-act:  #ffffff;
  --sidebar-border:   rgba(255,255,255,0.07);

  /* Surfaces */
  --bg:           #f8fafc;
  --surface:      #ffffff;
  --surface-alt:  #f8fafc;
  --surface-hover:#f1f5f9;

  /* Bordures */
  --border:       #e2e8f0;
  --border-light: #f1f5f9;
  --border-focus: #93c5fd;

  /* Texte */
  --txt:          #0f172a;
  --txt-2:        #334155;
  --txt-muted:    #64748b;
  --txt-faint:    #94a3b8;

  /* Sémantique */
  --success:        #10b981;
  --success-hover:  #059669;
  --success-light:  #ecfdf5;
  --success-border: #a7f3d0;
  --success-text:   #065f46;

  --warning:        #f59e0b;
  --warning-hover:  #d97706;
  --warning-light:  #fffbeb;
  --warning-border: #fde68a;
  --warning-text:   #92400e;

  --danger:         #ef4444;
  --danger-hover:   #dc2626;
  --danger-light:   #fef2f2;
  --danger-border:  #fecaca;
  --danger-text:    #991b1b;

  --info:           #0284c7;
  --info-hover:     #0369a1;
  --info-light:     #f0f9ff;
  --info-border:    #bae6fd;
  --info-text:      #075985;

  --purple:         #8b5cf6;
  --purple-hover:   #7c3aed;
  --purple-light:   #f5f3ff;
  --purple-border:  #ddd6fe;
  --purple-text:    #5b21b6;

  /* Spacing */
  --radius-xs:  4px;
  --radius-sm:  6px;
  --radius:     8px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  16px;

  /* Shadow */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-lg:  0 10px 30px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
  --shadow-xl:  0 20px 50px rgba(0,0,0,0.14), 0 4px 12px rgba(0,0,0,0.08);

  /* Topbar */
  --topbar-h:   60px;

  /* Typography */
  --font:       'Inter', system-ui, -apple-system, sans-serif;
  --text-xs:    11px;
  --text-sm:    12px;
  --text-base:  13px;
  --text-md:    14px;
  --text-lg:    16px;
  --text-xl:    20px;
  --text-2xl:   24px;
  --text-3xl:   30px;
}

:root[data-theme="dark"],
[data-theme="dark"] {
  --bg:           #090e17;
  --surface:      #111827;
  --surface-alt:  #162032;
  --surface-hover:#1e293b;

  --border:       #243249;
  --border-light: #1b263b;
  --border-focus: #3b82f6;

  --txt:          #f8fafc;
  --txt-2:        #cbd5e1;
  --txt-muted:    #94a3b8;
  --txt-faint:    #64748b;

  --primary:        #3b82f6;
  --primary-hover:  #60a5fa;
  --primary-light:  rgba(59, 130, 246, 0.16);
  --primary-border: rgba(59, 130, 246, 0.35);
  --primary-text:   #93c5fd;

  --secondary:      #e2e8f0;
  --secondary-hover:#ffffff;
  --secondary-light:#1e293b;

  --shadow-xs:  0 1px 2px rgba(0,0,0,0.5);
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.45), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 14px rgba(0,0,0,0.55), 0 1px 3px rgba(0,0,0,0.35);
  --shadow-lg:  0 10px 30px rgba(0,0,0,0.65);
  --shadow-xl:  0 20px 50px rgba(0,0,0,0.75);
}

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

html { font-size: 14px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--txt);
  display: flex;
  min-height: 100vh;
  font-size: var(--text-base);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

/* ── App Shell ─────────────────────────────────────────────── */
.app-container {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.side {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--sidebar-border);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow: visible;
  z-index: 50;
  scrollbar-width: none;
  transition: width .24s ease;
}
.side::-webkit-scrollbar { display: none; }

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(37,99,235,0.35);
}
img.brand-icon {
  object-fit: contain;
  background: transparent;
  box-shadow: none;
  border-radius: 6px;
}
.brand-name {
  font-size: 15px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.3px;
  line-height: 1.1;
}
.brand-tag {
  font-size: 9px;
  font-weight: 700;
  color: #4b6cb7;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-top: 1px;
}
/* Commande de réduction du menu */
.sidebar-toggle-wrap {
  position: absolute;
  top: 70px;
  right: -13px;
  z-index: 60;
  width: 27px;
  height: 27px;
}
.sidebar-toggle {
  width: 27px;
  height: 27px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  padding: 0;
  font-size: 13px;
  box-shadow: 0 3px 10px rgba(15,23,42,.25);
  cursor: pointer;
  transition: background .15s, transform .24s ease, box-shadow .15s;
}
.sidebar-toggle:hover {
  background: var(--primary-hover);
  color: #fff;
  box-shadow: 0 5px 14px rgba(37,99,235,.35);
}
.sidebar-toggle i { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }

/* Company selector */
.company-selector {
  margin: 12px 12px 0;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius);
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background 0.15s;
}
.company-selector:hover { background: rgba(255,255,255,0.09); }
.company-selector-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.company-selector-icon {
  font-size: 10px;
  color: var(--sidebar-text);
  flex-shrink: 0;
  margin-left: 6px;
}

/* Nav sections */
.side nav {
  padding: 10px 10px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(148,163,184,.28) transparent;
}
.side nav::-webkit-scrollbar { width: 4px; }
.side nav::-webkit-scrollbar-track { background: transparent; }
.side nav::-webkit-scrollbar-thumb { background: rgba(148,163,184,.28); border-radius: 4px; }

.nav-section-label,
.nav-section-toggle {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #7183a0;
  padding: 12px 8px 6px;
}
.nav-section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.nav-section-toggle:hover { color: #dbeafe; background: rgba(255,255,255,.04); }
.nav-section-group.has-active > .nav-section-toggle {
  color: #93c5fd;
  background: rgba(37,99,235,.12);
  border-radius: var(--radius-sm);
}
.nav-section-group.has-active > .nav-section-toggle .section-icon { color: #60a5fa; }
.nav-section-toggle .section-icon { width: 16px; font-size: 13px; text-align: center; }
.nav-section-toggle .section-chevron { margin-left: auto; font-size: 10px; transition: transform .22s ease; }
.nav-section-group.is-collapsed .section-chevron { transform: rotate(-90deg); }
.nav-section-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 900px;
  overflow: hidden;
  opacity: 1;
  transition: max-height .24s ease, opacity .18s ease;
}
.nav-section-group.is-collapsed .nav-section-links { max-height: 0; opacity: 0; }

.side nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--sidebar-text);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.side nav a i.bi {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.65;
  transition: opacity 0.12s;
}
.side nav a:hover {
  background: var(--sidebar-hover);
  color: #cbd5e1;
}
.side nav a:hover i.bi { opacity: 0.9; }
.side nav a.active {
  background: rgba(37,99,235,0.18);
  color: #93c5fd;
  font-weight: 600;
}
.side nav a.active i.bi { opacity: 1; color: #60a5fa; }
.side nav a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: #3b82f6;
  border-radius: 0 3px 3px 0;
}

/* Sidebar footer */
.side-footer {
  padding: 14px 10px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.side-footer a {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #ef4444;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}
.side-footer a:hover { background: rgba(239,68,68,0.1); }

/* ── Main Wrapper ──────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: var(--sidebar-w);
  transition: margin-left .24s ease;
}

/* Mode compact : la largeur diminue, mais les icônes restent accessibles. */
.app-container.sidebar-collapsed .side { width: var(--sidebar-collapsed-w); }
.app-container.sidebar-collapsed .main-wrapper { margin-left: var(--sidebar-collapsed-w); }
.app-container.sidebar-collapsed .brand { justify-content: center; padding-left: 10px; padding-right: 10px; }
.app-container.sidebar-collapsed .brand > div:not(.brand-icon),
.app-container.sidebar-collapsed .company-selector-name,
.app-container.sidebar-collapsed .nav-section-label,
.app-container.sidebar-collapsed .nav-section-toggle span,
.app-container.sidebar-collapsed .nav-section-toggle .section-chevron,
.app-container.sidebar-collapsed .side-footer a span { display: none; }
.app-container.sidebar-collapsed .sidebar-toggle-wrap { right: -13px; }
.app-container.sidebar-collapsed .company-selector {
  justify-content: center;
  margin-left: 10px;
  margin-right: 10px;
  padding-left: 0;
  padding-right: 0;
}
.app-container.sidebar-collapsed .company-selector-icon { margin-left: 0; font-size: 13px; }
.app-container.sidebar-collapsed .side nav { padding-left: 8px; padding-right: 8px; }
.app-container.sidebar-collapsed .nav-section-toggle {
  justify-content: center;
  padding: 9px 0 5px;
}
.app-container.sidebar-collapsed .nav-section-toggle .section-icon { width: 28px; font-size: 16px; }
.app-container.sidebar-collapsed .side nav a {
  justify-content: center;
  gap: 0;
  padding-left: 0;
  padding-right: 0;
  font-size: 0;
}
.app-container.sidebar-collapsed .side nav a i.bi { width: 28px; font-size: 18px; opacity: .8; }
.app-container.sidebar-collapsed .side nav a.active::before { left: -1px; }
.app-container.sidebar-collapsed .side nav > div[style] { opacity: 0; margin-top: 3px !important; margin-bottom: 3px !important; }
.app-container.sidebar-collapsed .side-footer { padding-left: 8px; padding-right: 8px; }
.app-container.sidebar-collapsed .side-footer a { justify-content: center; gap: 0; padding-left: 0; padding-right: 0; }
.app-container.sidebar-collapsed .side-footer a i { font-size: 16px; }

@media (max-width: 900px) {
  .top-bar { padding-left: 14px; padding-right: 14px; }
}

/* ── Top Bar ───────────────────────────────────────────────── */
.top-bar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-xs);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--txt-muted);
}
.breadcrumbs .bc-sep { color: var(--txt-faint); }
.breadcrumbs strong { color: var(--txt); font-weight: 700; }

.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Search */
.top-search {
  position: relative;
  display: flex;
  align-items: center;
}
.top-search-results {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 2100;
  width: min(380px, calc(100vw - 28px)); max-height: 420px; overflow: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 14px 36px rgba(15,23,42,.16); padding: 6px;
}
.top-search-results[hidden], .notification-dropdown[hidden] { display: none; }
.top-search-result { display: flex; align-items: center; gap: 10px; padding: 10px 11px; border-radius: 8px; color: var(--txt); text-decoration: none; font-size: 13px; }
.top-search-result:hover, .top-search-result[aria-selected="true"] { background: var(--surface-alt); }
.top-search-result i { color: var(--primary); }
.top-search-group { padding: 8px 10px 4px; color: var(--txt-faint); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.top-search-message { padding: 14px 11px; color: var(--txt-muted); font-size: 12px; }
.top-search > i {
  position: absolute;
  left: 11px;
  color: var(--txt-faint);
  font-size: 13px;
  pointer-events: none;
}
.top-search input {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px 6px 32px;
  font-size: 12.5px;
  width: 220px;
  color: var(--txt);
  transition: all 0.2s;
}
.top-search input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  width: 260px;
}
.top-search input::placeholder { color: var(--txt-faint); }

/* Mia IA Masquée de l'application */
.btn-mia,
#miaDrawer,
.mia-drawer,
.mia-backdrop,
.mia-fab {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Notifications bell */
.top-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--txt-muted);
  font-size: 15px;
  transition: all 0.15s;
  position: relative;
}
.top-icon-btn:hover { background: var(--surface-alt); color: var(--txt); }
.top-icon-btn .badge-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: #ef4444;
  border-radius: 50%;
  border: 1.5px solid #fff;
}
.top-icon-btn .badge-dot[hidden] { display: none; }
/* ── Notifications Dropdown Redesign ── */
.notification-wrapper { position: relative; }
.notification-dropdown {
  position: absolute;
  z-index: 2200;
  top: calc(100% + 12px);
  right: -36px;
  width: min(440px, calc(100vw - 24px));
  max-height: min(600px, calc(100vh - 85px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 18px;
  box-shadow: 0 20px 48px -10px rgba(15, 23, 42, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.04);
  backdrop-filter: blur(12px);
  animation: notifDropdownIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: top right;
}
@keyframes notifDropdownIn {
  from { opacity: 0; transform: scale(0.96) translateY(-6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.notification-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface-alt, #f8fafc);
  border-bottom: 1px solid var(--border, #e2e8f0);
}
.notif-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.notif-header-icon-box {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.notif-header-title strong {
  font-size: 15px;
  font-weight: 800;
  color: var(--txt, #0f172a);
  letter-spacing: -0.2px;
}
.notif-unread-count-pill {
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  background: #2563eb;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}
.notif-readall-btn {
  border: 1px solid var(--border, #cbd5e1);
  background: var(--surface, #ffffff);
  color: var(--txt-2, #334155);
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}
.notif-readall-btn:hover {
  background: #eff6ff;
  color: #2563eb;
  border-color: #bfdbfe;
}

/* Filter bar (Toutes / Non lues) */
.notif-filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--surface, #ffffff);
  border-bottom: 1px solid var(--border-light, #f1f5f9);
}
.notif-filter-btn {
  border: none;
  background: transparent;
  color: var(--txt-muted, #64748b);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.notif-filter-btn:hover {
  color: var(--txt, #0f172a);
  background: var(--surface-alt, #f1f5f9);
}
.notif-filter-btn.active {
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}
.notif-tab-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.07);
  color: inherit;
}
.notif-tab-badge.is-unread {
  background: #ef4444;
  color: #fff;
}

/* List container */
.notification-list {
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
}
.notification-list::-webkit-scrollbar {
  width: 5px;
}
.notification-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 4px;
}

/* Notification Item Card */
.notification-card {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  text-decoration: none;
  color: inherit;
}
.notification-card:hover {
  background: var(--surface-hover, #f8fafc);
  border-color: #cbd5e1;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
  transform: translateY(-1px);
}
.notification-card.is-unread {
  background: #f8fafc;
  border-left: 3.5px solid #2563eb;
  border-color: #cbd5e1 #cbd5e1 #cbd5e1 #2563eb;
}
.notification-card.is-unread .notif-unread-glow {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2563eb;
  position: absolute;
  top: 14px;
  right: 14px;
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.6);
}

/* Icon Avatar */
.notif-icon-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}
.notif-theme-marketing .notif-icon-avatar {
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  color: #7c3aed;
}
.notif-theme-stock .notif-icon-avatar {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #d97706;
}
.notif-theme-expense .notif-icon-avatar {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: #059669;
}
.notif-theme-production .notif-icon-avatar {
  background: linear-gradient(135deg, #cffafe, #a5f3fc);
  color: #0891b2;
}
.notif-theme-qhse .notif-icon-avatar {
  background: linear-gradient(135deg, #ccfbf1, #99f6e4);
  color: #0d9488;
}
.notif-theme-projects .notif-icon-avatar {
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
  color: #4f46e5;
}
.notif-theme-default .notif-icon-avatar {
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  color: #2563eb;
}

/* Content Container */
.notif-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Top Meta Row */
.notif-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-right: 14px;
}
.notif-category-chip {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 1px 7px;
  border-radius: 5px;
}
.notif-theme-marketing .notif-category-chip { background: #f3e8ff; color: #7c3aed; }
.notif-theme-stock .notif-category-chip { background: #fef3c7; color: #b45309; }
.notif-theme-expense .notif-category-chip { background: #ecfdf5; color: #047857; }
.notif-theme-production .notif-category-chip { background: #ecfeff; color: #0e7490; }
.notif-theme-qhse .notif-category-chip { background: #f0fdfa; color: #0f766e; }
.notif-theme-projects .notif-category-chip { background: #eef2ff; color: #4338ca; }
.notif-theme-default .notif-category-chip { background: #eff6ff; color: #1d4ed8; }

.notif-severity-pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.notif-severity-pill.danger {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}
.notif-severity-pill.warning {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}
.notif-severity-pill.success {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}
.notif-severity-pill.info {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.notif-time {
  font-size: 11px;
  color: var(--txt-muted, #94a3b8);
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* Title & Scope */
.notif-title-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
.notif-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--txt, #0f172a);
  line-height: 1.35;
  word-break: break-word;
}
.notif-scope-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--txt-2, #334155);
  background: var(--surface-alt, #f1f5f9);
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--border-light, #e2e8f0);
}

/* Body Text */
.notif-card-desc {
  font-size: 12px;
  color: var(--txt-muted, #64748b);
  line-height: 1.45;
  margin: 0;
}

/* Metric / Progress Box (for Budget & Thresholds) */
.notif-metric-box {
  margin-top: 4px;
  padding: 8px 10px;
  background: var(--surface-alt, #f8fafc);
  border: 1px solid var(--border-light, #f1f5f9);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.notif-metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}
.notif-metric-label {
  color: var(--txt-muted, #64748b);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.notif-metric-value {
  font-weight: 800;
  font-size: 11.5px;
}
.notif-metric-value.progress-danger { color: #dc2626; }
.notif-metric-value.progress-warning { color: #d97706; }
.notif-metric-value.progress-primary { color: #2563eb; }

.notif-progress-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}
.notif-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.notif-progress-fill.progress-danger {
  background: linear-gradient(90deg, #ef4444, #dc2626);
}
.notif-progress-fill.progress-warning {
  background: linear-gradient(90deg, #f59e0b, #d97706);
}
.notif-progress-fill.progress-primary {
  background: linear-gradient(90deg, #3b82f6, #2563eb);
}

.notif-metric-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.notif-metric-warning {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

/* Card Actions Footer */
.notif-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-light, #f1f5f9);
}
.notif-jump-link {
  font-size: 11.5px;
  font-weight: 700;
  color: #2563eb;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}
.notif-jump-link:hover {
  color: #1d4ed8;
  text-decoration: underline;
}
.notif-action-btns {
  display: flex;
  align-items: center;
  gap: 4px;
}
.notif-btn-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--txt-muted, #94a3b8);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.notif-btn-icon:hover {
  background: var(--surface-alt, #f1f5f9);
  color: var(--txt, #0f172a);
  border-color: var(--border, #e2e8f0);
}
.notif-btn-icon.delete:hover {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

/* Dropdown Footer */
.notification-dropdown-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface-alt, #f8fafc);
  border-top: 1px solid var(--border, #e2e8f0);
}
.notif-footer-hint {
  font-size: 11px;
  color: var(--txt-muted, #94a3b8);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.notif-footer-refresh-btn {
  border: none;
  background: transparent;
  color: #2563eb;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.notif-footer-refresh-btn:hover {
  background: rgba(37, 99, 235, 0.08);
}

/* Empty State */
.notification-empty-state {
  padding: 36px 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.notif-empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.08);
  color: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 4px;
}
.notification-empty-state strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--txt, #0f172a);
}
.notification-empty-state p {
  margin: 0;
  font-size: 12px;
  color: var(--txt-muted, #64748b);
  max-width: 240px;
  line-height: 1.4;
}

/* Avatar */
.user-avatar {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(37,99,235,0.25);
}

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
}

/* ── Page Header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
  gap: 16px;
}
.page-header-left {}
.page-header-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--primary);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.page-header-eyebrow::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--primary);
  border-radius: 50%;
}
.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--txt);
  letter-spacing: -0.4px;
  line-height: 1.2;
}
.page-subtitle {
  font-size: 12.5px;
  color: var(--txt-muted);
  margin-top: 4px;
  line-height: 1.5;
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── KPI Cards & Statistics ───────────────────────────────── */
.kpi-grid,
.hr-stats-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 22px;
}
.kpi-grid-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-grid-2 { grid-template-columns: repeat(2, 1fr); }

.kpi-card,
.stat-card,
.hr-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.kpi-card:hover,
.stat-card:hover,
.hr-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -4px rgba(15, 23, 42, 0.08);
  border-color: #cbd5e1;
}

.kpi-card::before,
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  transition: background 0.16s ease;
}

/* KPI Color themes */
.kpi-card.blue,
.kpi-card.color-blue,
.stat-card.blue {
  background: #f8fbff;
  border-color: var(--primary-border);
}
.kpi-card.blue::before,
.kpi-card.color-blue::before { background: var(--primary); }

.kpi-card.green,
.kpi-card.color-green,
.stat-card.green {
  background: #f8fdfa;
  border-color: var(--success-border);
}
.kpi-card.green::before,
.kpi-card.color-green::before { background: var(--success); }

.kpi-card.amber,
.kpi-card.color-amber,
.kpi-card.warning,
.stat-card.amber {
  background: #fffdf7;
  border-color: var(--warning-border);
}
.kpi-card.amber::before,
.kpi-card.color-amber::before { background: var(--warning); }

.kpi-card.red,
.kpi-card.color-red,
.kpi-card.danger,
.stat-card.red {
  background: #fef9f9;
  border-color: var(--danger-border);
}
.kpi-card.red::before,
.kpi-card.color-red::before { background: var(--danger); }

.kpi-card.purple,
.kpi-card.color-purple,
.stat-card.purple {
  background: #faf8ff;
  border-color: var(--purple-border);
}
.kpi-card.purple::before,
.kpi-card.color-purple::before { background: var(--purple); }

/* KPI internal elements */
.kpi-label,
.stat-label,
.hr-stat-lbl,
.detail-kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--txt-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-val,
.stat-val,
.stat-value,
.hr-stat-val,
.detail-kpi-val {
  font-size: 24px;
  font-weight: 800;
  color: var(--txt);
  line-height: 1.18;
  letter-spacing: -0.4px;
}

.kpi-sub,
.stat-sub,
.stat-change {
  font-size: 12px;
  color: var(--txt-muted);
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.kpi-sub.up, .stat-change.up     { color: var(--success); font-weight: 600; }
.kpi-sub.down, .stat-change.down { color: var(--danger);  font-weight: 600; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  overflow-x: auto;
  max-width: 100%;
}
.card-body { padding: 20px; }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--txt);
}
.card-subtitle {
  font-size: 12px;
  color: var(--txt-muted);
  margin-top: 2px;
}

/* ── Grid helpers ──────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }
.grid-half { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ── Universal Button System (.btn & .ui-btn & .hr-btn) ─────── */
.btn,
.ui-btn,
.hr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  white-space: nowrap;
  height: 36px;
  min-height: 36px;
  box-sizing: border-box;
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn:hover,
.ui-btn:hover,
.hr-btn:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 3px 10px rgba(37,99,235,0.25);
  transform: translateY(-1px);
}

.btn:active,
.ui-btn:active,
.hr-btn:active {
  transform: translateY(0) scale(0.98);
  box-shadow: none;
}

.btn:disabled,
.ui-btn:disabled,
.hr-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Primary Variant */
.btn-primary,
.ui-btn-primary,
.hr-btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover,
.ui-btn-primary:hover,
.hr-btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 3px 10px rgba(37,99,235,0.28);
}

/* Secondary Variant */
.btn-secondary,
.ui-btn-secondary {
  background: #0f172a;
  color: #fff;
  border-color: #0f172a;
}
.btn-secondary:hover,
.ui-btn-secondary:hover {
  background: #1e293b;
  border-color: #1e293b;
  box-shadow: 0 3px 10px rgba(15,23,42,0.2);
}

/* Outline Variant */
.btn-outline,
.ui-btn-outline,
.hr-btn-outline {
  background: var(--surface);
  color: var(--txt-2);
  border-color: var(--border);
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.btn-outline:hover,
.ui-btn-outline:hover,
.hr-btn-outline:hover {
  background: var(--surface-alt);
  border-color: #cbd5e1;
  color: var(--txt);
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.btn-outline:active,
.ui-btn-outline:active,
.hr-btn-outline:active {
  background: #e2e8f0;
}

/* Ghost Variant */
.btn-ghost,
.ui-btn-ghost {
  background: transparent;
  color: var(--txt-muted);
  border-color: transparent;
}
.btn-ghost:hover,
.ui-btn-ghost:hover {
  background: var(--surface-alt);
  color: var(--txt);
  box-shadow: none;
}

/* Danger Variant */
.btn-danger,
.ui-btn-danger,
.hr-btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover,
.ui-btn-danger:hover,
.hr-btn-danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  box-shadow: 0 3px 10px rgba(239,68,68,0.28);
}

/* Danger Outline */
.btn-danger-outline,
.ui-btn-danger-outline {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn-danger-outline:hover,
.ui-btn-danger-outline:hover {
  background: var(--danger-light);
  border-color: var(--danger);
}

/* Success Variant */
.btn-success,
.ui-btn-success,
.hr-btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover,
.ui-btn-success:hover,
.hr-btn-success:hover {
  background: var(--success-hover);
  border-color: var(--success-hover);
  box-shadow: 0 3px 10px rgba(16,185,129,0.28);
}

/* WhatsApp Variant */
.btn-whatsapp {
  background: #16a34a;
  color: #fff;
  border-color: #16a34a;
}
.btn-whatsapp:hover {
  background: #15803d;
  border-color: #15803d;
  box-shadow: 0 3px 10px rgba(22,163,74,0.28);
}

/* Button Sizing */
.btn-sm,
.ui-btn-sm,
.hr-btn-sm {
  height: 30px;
  min-height: 30px;
  padding: 0 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  gap: 5px;
}

.btn-xs,
.ui-btn-xs {
  height: 24px;
  min-height: 24px;
  padding: 0 8px;
  font-size: 11px;
  border-radius: var(--radius-xs);
  gap: 4px;
}

.btn-lg,
.ui-btn-lg {
  height: 42px;
  min-height: 42px;
  padding: 0 22px;
  font-size: 14px;
  border-radius: var(--radius-md);
  gap: 8px;
}

.btn-icon,
.btn-icon-only {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: var(--radius);
}
.btn-icon.btn-sm,
.btn-icon-only.btn-sm {
  width: 30px;
  height: 30px;
  min-height: 30px;
  border-radius: var(--radius-sm);
}

/* Recette / Dépense specialized buttons */
.btn-recette {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  height: 36px;
  min-height: 36px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--success);
  background: var(--success);
  color: #fff;
  transition: all 0.15s ease;
}
.btn-recette:hover {
  background: var(--success-hover);
  border-color: var(--success-hover);
  box-shadow: 0 3px 10px rgba(16,185,129,0.28);
  transform: translateY(-1px);
}
.btn-depense {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  height: 36px;
  min-height: 36px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--danger);
  background: var(--danger);
  color: #fff;
  transition: all 0.15s ease;
}
.btn-depense:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  box-shadow: 0 3px 10px rgba(239,68,68,0.28);
  transform: translateY(-1px);
}

/* Action button aliases for table rows */
.icon-btn,
.ui-action-btn {
  width: 30px;
  height: 30px;
  min-width: 30px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid var(--border, #e2e8f0);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  transition: background .12s, border-color .12s, color .12s, transform .08s;
  background: var(--surface, #ffffff);
  color: var(--txt-2, #334155);
}
.icon-btn:hover,
.ui-action-btn:hover {
  background: var(--surface-alt, #f8fafc);
  border-color: #94a3b8;
  color: var(--txt, #0f172a);
}
.icon-btn:active,
.ui-action-btn:active {
  transform: scale(.93);
}
.icon-btn.text-red,
.icon-btn.btn-del,
.icon-btn.btn-delete,
.icon-btn[title*="Supprimer"],
.ui-action-delete {
  color: #b91c1c;
  border-color: #fca5a5;
  background: #fef2f2;
}
.icon-btn.text-red:hover,
.icon-btn.btn-del:hover,
.icon-btn.btn-delete:hover,
.icon-btn[title*="Supprimer"]:hover,
.ui-action-delete:hover {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
}

/* ── Badges & Tags ─────────────────────────────────────────── */
.badge,
.ui-badge,
.hr-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: all 0.12s ease;
}
.badge::before,
.ui-badge::before,
.hr-badge::before,
.status-badge::before {
  content: none !important;
  display: none !important;
}

.badge-success,
.ui-badge-success,
.hr-badge-approved,
.hr-badge-completed {
  background: var(--success-light);
  color: var(--success-text);
  border-color: var(--success-border);
}

.badge-warning,
.ui-badge-warning,
.hr-badge-pending,
.hr-badge-waiting {
  background: var(--warning-light);
  color: var(--warning-text);
  border-color: var(--warning-border);
}

.badge-danger,
.ui-badge-danger,
.hr-badge-rejected,
.hr-badge-cancelled {
  background: var(--danger-light);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

.badge-info,
.ui-badge-info,
.hr-badge-in_review,
.hr-badge-processing {
  background: var(--info-light);
  color: var(--info-text);
  border-color: var(--info-border);
}

.badge-draft,
.ui-badge-draft,
.badge-secondary,
.badge-neutral {
  background: var(--surface-alt);
  color: #475569;
  border-color: var(--border);
}

.badge-purple,
.ui-badge-purple {
  background: var(--purple-light);
  color: var(--purple-text);
  border-color: var(--purple-border);
}

.ref-badge {
  display: inline-block;
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--primary-light);
  color: var(--primary);
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary-border);
  text-decoration: none;
  letter-spacing: 0.2px;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.ref-badge:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

/* ── Tables ────────────────────────────────────────────────── */
table { width: 100%; border-collapse: separate; border-spacing: 0; }

thead th {
  background: var(--surface-alt);
  color: var(--txt-muted);
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.55px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--txt-2);
  font-size: 13px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

th.col-num, td.col-num { text-align: right; }
th.col-center, td.col-center { text-align: center; }
th.col-actions, td.col-actions {
  text-align: right;
  white-space: nowrap;
  width: 1%;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--txt-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-label .req { color: var(--danger); margin-left: 2px; }

.form-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-family: var(--font);
  font-size: 13px;
  color: var(--txt);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-input::placeholder { color: var(--txt-faint); }
.form-input[disabled] { background: var(--surface-alt); color: var(--txt-muted); cursor: not-allowed; }

textarea.form-input { resize: vertical; min-height: 80px; }
select.form-input { cursor: pointer; }

/* ── Toggle Switch ─────────────────────────────────────────── */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.toggle-track {
  position: relative;
  width: 40px;
  height: 22px;
}
.toggle-track input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 11px;
  transition: background 0.2s;
  cursor: pointer;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-track input:checked + .toggle-slider { background: var(--primary); }
.toggle-track input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle-label { font-size: 13px; font-weight: 600; color: var(--txt-2); }

/* ── Tabs (document tabs) ──────────────────────────────────── */
.doc-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: -1px;
}
.doc-tab {
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--txt-muted);
  transition: color 0.12s, border-color 0.12s, background 0.1s;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  white-space: nowrap;
}
.doc-tab:hover { color: var(--txt-2); background: var(--surface-alt); }
.doc-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: transparent;
}
.doc-tab:active { transform: scale(0.98); }

/* ── Universal Modal System ────────────────────────────────── */
.modal-overlay,
.ui-modal,
.hr-modal-overlay,
.ui-modal-backdrop,
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  box-sizing: border-box;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Modals inactive by default when without .active/.open and without inline flex/block */
.modal-overlay:not(.active):not(.open):not([style*="display: flex"]):not([style*="display:flex"]):not([style*="display: block"]):not([style*="display:block"]):not([data-visible="true"]),
.ui-modal:not(.active):not(.open):not([style*="display: flex"]):not([style*="display:flex"]):not([style*="display: block"]):not([style*="display:block"]):not([data-visible="true"]),
.hr-modal-overlay:not(.active):not(.open):not([style*="display: flex"]):not([style*="display:flex"]):not([style*="display: block"]):not([style*="display:block"]):not([data-visible="true"]),
.ui-modal-backdrop:not(.active):not(.open):not([style*="display: flex"]):not([style*="display:flex"]):not([style*="display: block"]):not([style*="display:block"]),
.modal-backdrop:not(.active):not(.open):not([style*="display: flex"]):not([style*="display:flex"]):not([style*="display: block"]):not([style*="display:block"]) {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* When active, open, OR when displayed via inline display:flex / display:block */
.modal-overlay.active,
.modal-overlay.open,
.modal-overlay[style*="display: flex"],
.modal-overlay[style*="display:flex"],
.modal-overlay[style*="display: block"],
.modal-overlay[style*="display:block"],
.ui-modal.active,
.ui-modal.open,
.ui-modal[style*="display: flex"],
.ui-modal[style*="display:flex"],
.ui-modal[style*="display: block"],
.ui-modal[style*="display:block"],
.hr-modal-overlay.active,
.hr-modal-overlay.open,
.hr-modal-overlay[style*="display: flex"],
.hr-modal-overlay[style*="display:flex"],
.ui-modal-backdrop.active,
.ui-modal-backdrop.open,
.ui-modal-backdrop[style*="display: flex"],
.ui-modal-backdrop[style*="display:flex"],
.modal-backdrop.active,
.modal-backdrop.open,
.modal-backdrop[style*="display: flex"],
.modal-backdrop[style*="display:flex"],
.modal-backdrop[style*="display: block"],
.modal-backdrop[style*="display:block"] {
  opacity: 1 !important;
  pointer-events: auto !important;
  display: flex !important;
}

/* Explicit inline display: none MUST be hidden */
.modal-overlay[style*="display: none"],
.modal-overlay[style*="display:none"],
.ui-modal[style*="display: none"],
.ui-modal[style*="display:none"],
.hr-modal-overlay[style*="display: none"],
.hr-modal-overlay[style*="display:none"],
.ui-modal-backdrop[style*="display: none"],
.ui-modal-backdrop[style*="display:none"],
.modal-backdrop[style*="display: none"],
.modal-backdrop[style*="display:none"] {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Modal Cards */
.modal-card,
.ui-modal-card,
.hr-modal-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(226, 232, 240, 0.9);
  width: 100%;
  max-width: 580px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px -12px rgba(15, 23, 42, 0.25), 0 10px 24px -6px rgba(15, 23, 42, 0.1);
  transform: translateY(14px) scale(0.98);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  min-height: 0;
  box-sizing: border-box;
}

.modal-card > form,
.ui-modal-card > form,
.hr-modal-card > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.modal-overlay.active .modal-card,
.modal-overlay.open .modal-card,
.modal-overlay[style*="display: flex"] .modal-card,
.modal-overlay[style*="display:flex"] .modal-card,
.ui-modal.active .modal-card,
.ui-modal.open .modal-card,
.ui-modal[style*="display: flex"] .modal-card,
.ui-modal[style*="display:flex"] .modal-card,
.ui-modal.active .ui-modal-card,
.ui-modal.open .ui-modal-card,
.ui-modal[style*="display: flex"] .ui-modal-card,
.ui-modal[style*="display:flex"] .ui-modal-card,
.hr-modal-overlay.active .hr-modal-card,
.hr-modal-overlay.open .hr-modal-card,
.hr-modal-overlay[style*="display: flex"] .hr-modal-card,
.hr-modal-overlay[style*="display:flex"] .hr-modal-card,
.ui-modal-backdrop.active .modal-card,
.ui-modal-backdrop.open .modal-card,
.ui-modal-backdrop[style*="display: flex"] .modal-card,
.ui-modal-backdrop[style*="display:flex"] .modal-card,
.modal-backdrop.active .modal-card,
.modal-backdrop.open .modal-card,
.modal-backdrop[style*="display: flex"] .modal-card,
.modal-backdrop[style*="display:flex"] .modal-card {
  transform: translateY(0) scale(1);
}

/* Modal Sizes */
.modal-card.sm,
.ui-modal--sm .modal-card,
.ui-modal-card.sm,
.modal-card[data-size="sm"] {
  max-width: 440px;
}

.modal-card.md,
.ui-modal--md .modal-card,
.ui-modal-card.md,
.modal-card[data-size="md"] {
  max-width: 580px;
}

.modal-card.lg,
.modal-card.modal-lg,
.ui-modal--lg .modal-card,
.ui-modal-card.lg,
.hr-modal-card.lg,
.modal-card[data-size="lg"] {
  max-width: 820px;
}

.modal-card.xl,
.ui-modal--xl .modal-card,
.ui-modal-card.xl,
.modal-card[data-size="xl"] {
  max-width: 1020px;
}

/* Modal Header */
.modal-header,
.ui-modal__header,
.ui-modal-header,
.hr-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface-alt);
  flex-shrink: 0;
}

.modal-title,
.ui-modal__title,
.ui-modal-title,
.hr-modal-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--txt);
  line-height: 1.25;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-subtitle,
.ui-modal__subtitle,
.ui-modal-subtitle,
.hr-modal-subtitle {
  font-size: 12px;
  color: var(--txt-muted);
  margin-top: 3px;
  font-weight: 400;
}

.modal-close,
.ui-modal__close,
.ui-modal-close,
.hr-modal-close,
.modal-close-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--txt-muted);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.modal-close:hover,
.ui-modal__close:hover,
.ui-modal-close:hover,
.hr-modal-close:hover,
.modal-close-btn:hover {
  background: #e2e8f0;
  color: var(--txt);
  border-color: #cbd5e1;
}

/* Modal Body */
.modal-body,
.ui-modal__body,
.ui-modal-body,
.hr-modal-body {
  padding: 22px 24px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  scrollbar-gutter: stable;
}

/* Modal Footer */
.modal-footer,
.ui-modal__footer,
.ui-modal-footer,
.hr-modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  background: var(--surface-alt);
}

/* ── Stepper ───────────────────────────────────────────────── */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  position: relative;
}
.stepper-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex: 1;
  position: relative;
}
.stepper-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 14px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
}
.stepper-step.done::after  { background: var(--success); }
.stepper-step.active::after { background: var(--primary-border); }

.step-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  color: var(--txt-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  z-index: 1;
}
.stepper-step.done   .step-circle { background: var(--success); color: #fff; }
.stepper-step.active .step-circle {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(37,99,235,0.18);
}
.step-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--txt-muted);
  white-space: nowrap;
}
.stepper-step.active .step-label { color: var(--primary); }
.stepper-step.done   .step-label { color: var(--success); }

/* ── Auth pages ────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8f0fe 0%, #f0f4ff 50%, #eff6ff 100%);
  padding: 24px;
}
.auth-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.auth-brand-icon {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #3b82f6);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(37,99,235,.35);
}
.auth-brand-name { color: var(--txt); font-size: 22px; font-weight: 800; line-height: 1.1; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-submit { width: 100%; margin-top: 8px; }
.auth-footer { margin-top: 24px; color: var(--txt-muted); font-size: 13.5px; text-align: center; }
.auth-footer a { color: var(--primary); font-weight: 600; }
.auth-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--txt);
  margin-bottom: 6px;
}
.auth-subtitle {
  font-size: 13px;
  color: var(--txt-muted);
  margin-bottom: 22px;
}

/* ── Mia Drawer ────────────────────────────────────────────── */
.mia-drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  height: 100vh;
  background: var(--surface);
  box-shadow: -8px 0 30px rgba(0,0,0,0.14);
  z-index: 300;
  display: flex;
  flex-direction: column;
  transition: right 0.28s cubic-bezier(0.4,0,0.2,1);
}
.mia-drawer.open { right: 0; }

.mia-drawer-header {
  padding: 16px 18px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.mia-drawer-messages {
  flex: 1;
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.45;
}
.msg-user { background: var(--primary); color: #fff; align-self: flex-end; border-bottom-right-radius: 3px; }
.msg-mia  { background: var(--surface-alt); color: var(--txt); align-self: flex-start; border-bottom-left-radius: 3px; border: 1px solid var(--border); }

.mia-drawer-input {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.mia-drawer-input input {
  flex: 1;
  border-radius: 20px;
  border: 1px solid var(--border);
  padding: 8px 14px;
  font-size: 13px;
  background: var(--surface-alt);
}
.mia-drawer-input input:focus { outline: none; border-color: var(--primary); background: var(--surface); }

/* ── Error pages ───────────────────────────────────────────── */
.error-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--bg);
  padding: 32px;
  gap: 16px;
}
.error-code {
  font-size: 96px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  opacity: 0.15;
}
.error-title { font-size: 22px; font-weight: 800; color: var(--txt); }
.error-msg   { font-size: 14px; color: var(--txt-muted); max-width: 380px; line-height: 1.6; }

/* ── Utilities ─────────────────────────────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--txt-muted); }
.fw-800 { font-weight: 800; }
.fw-700 { font-weight: 700; }
.fw-600 { font-weight: 600; }
.gap-8  { gap: 8px; }
.gap-10 { gap: 10px; }
.flex   { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.d-flex { display: flex !important; }
.align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 12px !important; }

/* Marges & espacements pour icônes et textes dans toute l'application */
.me-1, .mr-1 { margin-right: 6px !important; }
.me-2, .mr-2 { margin-right: 8px !important; }
.me-3, .mr-3 { margin-right: 12px !important; }
.me-4, .mr-4 { margin-right: 16px !important; }

.ms-1, .ml-1 { margin-left: 6px !important; }
.ms-2, .ml-2 { margin-left: 8px !important; }
.ms-3, .ml-3 { margin-left: 12px !important; }
.ms-4, .ml-4 { margin-left: 16px !important; }
.ms-auto, .ml-auto { margin-left: auto !important; }
.me-auto, .mr-auto { margin-right: auto !important; }

/* Espacement automatique global des icônes Bootstrap Icons */
i.bi {
  display: inline-block;
  vertical-align: -0.125em;
}

/* Quand une icône i.bi précède du texte (dans boutons, badges, titres, listes...) */
i.bi:not(:last-child):not(.no-margin) {
  margin-right: 7px;
}

/* Exclusion pour les boutons/conteneurs circulaires ou purement icônes (sidebar, topbar, actions) */
.side-rail-btn i.bi,
.top-icon-btn i.bi,
.btn-icon i.bi,
.ui-action-btn i.bi,
.kpi-icon-badge i.bi,
.contact-avatar-badge i.bi,
.chat-fab-btn i.bi,
.top-nav-pill i.bi {
  margin-right: 0 !important;
  margin-left: 0 !important;
}

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Global Print Styles (Reports, Stock Valuation, Catalog) ── */
@media print {
  .sidebar,
  .topbar,
  .page-header-actions,
  .ui-filter-bar,
  .col-actions,
  .ui-action-group,
  .mia-fab,
  .mia-drawer,
  .ui-modal-backdrop,
  .no-print {
    display: none !important;
  }
  body, .app-shell, .main-wrap, .page-content {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important;
  }
  .card, .ui-table-card {
    box-shadow: none !important;
    border: 1px solid #cbd5e1 !important;
    break-inside: avoid;
  }
}

/* ── Masquage chatbox sur landing page et pages d'authentification ── */
body.landing-body .chat-launcher-wrap,
body.landing-body #chatLauncherWrap,
body.landing-body #chatboxCard,
body.auth-body .chat-launcher-wrap,
body.auth-body #chatLauncherWrap,
body.auth-body #chatboxCard,
body[class*="landing"] .chat-launcher-wrap,
body[class*="landing"] #chatLauncherWrap,
body[class*="landing"] #chatboxCard,
body[class*="auth"] .chat-launcher-wrap,
body[class*="auth"] #chatLauncherWrap,
body[class*="auth"] #chatboxCard {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

