/* ============================================================
   AS CAPITAL OS — Design System CSS
   Inspiré de l'image dashboard (Construction Service)
   Adapté aux couleurs & modules AS CAPITAL
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Brand */
  --primary:       #1e293b;
  --accent:        #4f46e5;
  --accent-light:  #eef2ff;
  --accent-hover:  #4338ca;

  /* Sémantique */
  --success:       #10b981;
  --success-bg:    #d1fae5;
  --warning:       #f59e0b;
  --warning-bg:    #fef3c7;
  --danger:        #ef4444;
  --danger-bg:     #fee2e2;
  --info:          #3b82f6;
  --info-bg:       #dbeafe;

  /* Neutres */
  --bg-page:       #f8fafc;
  --bg-card:       #ffffff;
  --bg-hover:      #f1f5f9;
  --border:        #e2e8f0;
  --border-light:  #f1f5f9;

  /* Texte */
  --text-main:     #0f172a;
  --text-body:     #334155;
  --text-muted:    #64748b;
  --text-faint:    #94a3b8;

  /* Sidebar */
  --sidebar-bg:    #0f172a;
  --sidebar-w:     240px;
  --sidebar-w-sm:  68px;

  /* Shadows */
  --shadow-sm:     0 1px 2px rgba(0,0,0,.06);
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:     0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:     0 8px 24px rgba(0,0,0,.10);

  /* Radius */
  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     14px;

  /* Topbar */
  --topbar-h:      56px;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text-body);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

/* ── LAYOUT ─────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  transition: width .25s ease, min-width .25s ease;
  overflow: hidden;
  z-index: 100;
}

.sidebar.collapsed {
  width: var(--sidebar-w-sm);
  min-width: var(--sidebar-w-sm);
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

.brand-mark {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.brand-text { flex: 1; overflow: hidden; }
.brand-name { display: block; font-size: 13px; font-weight: 700; color: #f1f5f9; letter-spacing: .03em; white-space: nowrap; }
.brand-sub  { display: block; font-size: 10px; color: #475569; font-weight: 500; }

.sidebar-toggle {
  background: transparent; border: none; cursor: pointer;
  color: #475569; padding: 4px; border-radius: 4px;
  transition: color .15s; flex-shrink: 0;
}
.sidebar-toggle:hover { color: #94a3b8; }

/* Profil */
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,.05);
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: white;
  flex-shrink: 0;
}

.user-info { overflow: hidden; }
.user-name { display: block; font-size: 12.5px; font-weight: 600; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role-badge { display: inline-block; font-size: 10px; font-weight: 600; background: rgba(255,255,255,.1); color: #94a3b8; padding: 1px 7px; border-radius: 20px; margin-top: 2px; white-space: nowrap; }

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 99px; }

.nav-section-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #334155;
  padding: 12px 8px 4px;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: #64748b;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
  position: relative;
}

.nav-item:hover  { background: rgba(255,255,255,.06); color: #cbd5e1; }
.nav-item.active { background: var(--accent); color: white; }
.nav-item.active svg { stroke: white; }
.nav-label { overflow: hidden; text-overflow: ellipsis; }

/* Collapsed sidebar — cacher les labels */
.sidebar.collapsed .nav-label,
.sidebar.collapsed .brand-text,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .role-switcher,
.sidebar.collapsed .sidebar-logout span { display: none; }

.sidebar.collapsed .nav-item { justify-content: center; }
.sidebar.collapsed .sidebar-user { justify-content: center; }
.sidebar.collapsed .sidebar-brand { justify-content: center; }
.sidebar.collapsed .sidebar-logout { justify-content: center; }

/* Role switcher démo */
.role-switcher {
  padding: 10px 14px;
  border-top: 1px solid rgba(255,255,255,.05);
  flex-shrink: 0;
}
.switcher-label { font-size: 10px; color: #475569; font-weight: 500; margin-bottom: 6px; white-space: nowrap; }
.role-select {
  width: 100%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  color: #cbd5e1;
  font-family: inherit;
  font-size: 12px;
  padding: 6px 8px;
  cursor: pointer;
  outline: none;
}
.role-select option { background: #1e293b; }

/* Logout */
.sidebar-logout {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  color: #475569;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-top: 1px solid rgba(255,255,255,.05);
  transition: color .15s;
  flex-shrink: 0;
}
.sidebar-logout:hover { color: var(--danger); }

/* ── MAIN AREA ───────────────────────────────────────────── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── TOPBAR ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.topbar-menu-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 6px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.topbar-menu-btn:hover { background: var(--bg-hover); }

.topbar-title {
  font-size: 16px; font-weight: 700;
  color: var(--text-main); flex: 1;
  letter-spacing: -.01em;
}

.topbar-right {
  display: flex; align-items: center; gap: 12px;
}

.topbar-date {
  display: flex; align-items: center; gap: 5px;
  font-size: 12.5px; color: var(--text-muted); font-weight: 500;
}

.topbar-notif {
  position: relative; cursor: pointer;
  color: var(--text-muted); padding: 6px;
  border-radius: var(--radius-sm);
  transition: background .15s;
}
.topbar-notif:hover { background: var(--bg-hover); }
.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--danger); border-radius: 50%;
  border: 1.5px solid white;
}

.topbar-user { display: flex; align-items: center; gap: 8px; }
.topbar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white;
}
.topbar-username { font-size: 13px; font-weight: 600; color: var(--text-main); }

/* ── PAGE CONTENT ────────────────────────────────────────── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── KPI CARDS ───────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow .2s;
  min-width: 0;
}
.kpi-card:hover { box-shadow: var(--shadow-md); }

.kpi-header {
  display: flex; align-items: center; justify-content: space-between;
}

.kpi-label {
  font-size: 12px; font-weight: 600;
  color: var(--text-muted); letter-spacing: .02em;
}

.kpi-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-icon svg { width: 18px; height: 18px; }

.kpi-icon.indigo { background: #eef2ff; color: var(--accent); }
.kpi-icon.green  { background: #d1fae5; color: var(--success); }
.kpi-icon.amber  { background: #fef3c7; color: var(--warning); }
.kpi-icon.blue   { background: #dbeafe; color: var(--info); }
.kpi-icon.red    { background: #fee2e2; color: var(--danger); }
.kpi-icon.slate  { background: #f1f5f9; color: var(--text-main); }

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.kpi-footer {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 500;
}

.kpi-trend { display: flex; align-items: center; gap: 3px; }
.kpi-trend.up      { color: var(--success); }
.kpi-trend.down    { color: var(--danger); }
.kpi-trend.neutral { color: var(--text-muted); }
.kpi-trend svg  { width: 12px; height: 12px; }
.kpi-foot-label { color: var(--text-muted); }

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow);
  min-width: 0;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 14px; font-weight: 700;
  color: var(--text-main);
}

.card-body { padding: 20px; }

/* ── DEUX COLONNES ───────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  min-width: 0;
}

.two-col > div {
  min-width: 0;
  overflow: hidden;
}

/* ── TABLE ───────────────────────────────────────────────── */
.data-table-wrap { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background .1s;
  cursor: pointer;
}
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table td { padding: 12px 16px; vertical-align: middle; }

.mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* ── STATUS BADGE ────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  white-space: nowrap;
}
.badge::before { content:''; width:6px; height:6px; border-radius:50%; background:currentColor; opacity:.7; }

.badge-success { background: var(--success-bg); color: #065f46; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-danger  { background: var(--danger-bg);  color: #991b1b; }
.badge-info    { background: var(--info-bg);    color: #1e40af; }
.badge-neutral { background: #f1f5f9;           color: var(--text-muted); }
.badge-accent  { background: var(--accent-light); color: #3730a3; }

/* ── BOUTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent;
  transition: all .15s; white-space: nowrap;
  text-decoration: none;
}

.btn-primary  { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-outline  { background: white; color: var(--text-body); border-color: var(--border); }
.btn-outline:hover { background: var(--bg-hover); }

.btn-danger   { background: var(--danger); color: white; border-color: var(--danger); }
.btn-success  { background: var(--success); color: white; border-color: var(--success); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ── PIPELINE KANBAN ─────────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.kanban-col {
  min-width: 220px;
  background: #f8fafc;
  border-radius: var(--radius);
  padding: 12px;
  flex-shrink: 0;
}

.kanban-col-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase; letter-spacing: .05em;
}

.kanban-count {
  background: var(--border);
  color: var(--text-muted);
  font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 20px;
}

.kanban-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: box-shadow .15s;
}
.kanban-card:hover { box-shadow: var(--shadow-md); }

.kanban-card-name  { font-size: 13px; font-weight: 600; color: var(--text-main); margin-bottom: 4px; }
.kanban-card-meta  { font-size: 11.5px; color: var(--text-muted); }
.kanban-card-value { font-size: 13px; font-weight: 700; color: var(--accent); margin-top: 8px; font-variant-numeric: tabular-nums; }

/* ── FORMULAIRES ─────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.form-label { font-size: 12.5px; font-weight: 600; color: var(--text-body); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13.5px;
  color: var(--text-main);
  outline: none;
  transition: border-color .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.form-textarea { resize: vertical; min-height: 80px; }

/* ── LOGIN ───────────────────────────────────────────────── */
.login-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #0f172a 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.login-logo .brand-mark { width: 40px; height: 40px; border-radius: 10px; }
.login-logo .brand-name { font-size: 17px; }
.login-logo .brand-sub  { font-size: 12px; }
.login-title { font-size: 22px; font-weight: 700; color: var(--text-main); margin-bottom: 6px; }
.login-sub   { font-size: 13.5px; color: var(--text-muted); margin-bottom: 28px; }
.login-error {
  background: var(--danger-bg); color: #991b1b;
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 13px; margin-bottom: 16px;
}

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 48px 20px;
  color: var(--text-muted); text-align: center;
}
.empty-state svg { width: 48px; height: 48px; opacity: .35; }
.empty-state-title { font-size: 15px; font-weight: 700; color: var(--text-body); }
.empty-state-sub   { font-size: 13px; }

/* ── SCROLLBAR ───────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 200; transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.mobile-open { transform: translateX(0); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
}

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden; /* ← bloque tout scroll horizontal */
  max-width: 100vw;
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0; /* ← clé : empêche flex de dépasser */
  max-width: 100%;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden; /* ← bloque le scroll horizontal dans le contenu */
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}