/* APEXIA CRM V1 — Custom Styles */
:root {
  --touch-min: 44px; --radius: 8px; --radius-lg: 12px;

  /* ── CHARTE APEXIA DARK (navy / violet) ── */
  --ax-bg:        #0B1120;   /* fond principal bleu nuit très sombre */
  --ax-bg-sidebar:#070B14;   /* sidebar + sombre */
  --ax-bg-card:   #111A2E;   /* panneaux/cartes bleu nuit clair */
  --ax-bg-input:  #0F1626;   /* inputs */
  --ax-border:    #1E2A44;   /* bordures fines bleu/gris */
  --ax-ink:       #E6EDF7;   /* texte principal blanc-bleu */
  --ax-muted:     #8494B3;   /* texte secondaire gris/bleu clair */
  --ax-muted-2:   #5C6B8A;
  --ax-accent:    #6D5CE0;   /* violet/indigo APEXIA principal */
  --ax-accent-2:  #8B5CF6;
  --ax-blue:      #3B82F6;   /* infos / statuts neutres */
  --ax-green:     #10B981;   /* succès / encaissé / gagné */
  --ax-orange:    #F59E0B;   /* attention / relance */
  --ax-red:       #EF4444;   /* refus / perdu / erreur */
  --ax-hover:     #16203A;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4B5563; }

/* Sidebar links */
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius);
  font-size: 0.875rem; color: var(--ax-muted);
  transition: all 0.15s; text-decoration: none;
  min-height: var(--touch-min);
}
.sidebar-link:hover { background: var(--ax-hover); color: var(--ax-ink); }
.sidebar-link.active { background: linear-gradient(135deg, var(--ax-accent), var(--ax-accent-2)); color: #fff; }
.sidebar-section-title {
  font-size: 0.675rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--ax-muted-2); padding: 8px 12px 4px 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Control Center return button — solid dark blue/violet, white text */
.cc-sidebar-btn {
  display: block; width: 100%; box-sizing: border-box;
  margin-bottom: 12px; padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid #8B5CF6; /* violet border */
  background: linear-gradient(135deg, #1E1B4B 0%, #4C1D95 100%); /* dark blue/violet */
  color: #FFF; text-align: center;
  font-size: 0.875rem; font-weight: 600;
  text-decoration: none; line-height: 1.25;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.cc-sidebar-btn:hover {
  background: linear-gradient(135deg, #312E81 0%, #5B21B6 100%); /* brighter, still dark */
  border-color: #A78BFA; color: #FFF;
}
.cc-sidebar-btn:focus-visible {
  outline: 3px solid #A78BFA; outline-offset: 2px; color: #FFF;
}

/* Sidebar user footer — integrated dark footer */
.cc-sidebar-user {
  background: var(--ax-bg-sidebar); border-top: 1px solid var(--ax-border);
  padding: 14px 16px;
}
.cc-sidebar-user .cc-avatar {
  width: 2rem; height: 2rem; border-radius: 9999px;
  background: var(--ax-accent); /* violet logo A unchanged */
  display: flex; align-items: center; justify-content: center;
  color: #FFF; font-size: 0.875rem; font-weight: 500; flex: none;
}
.cc-sidebar-user .cc-username { color: var(--ax-ink); font-weight: 500; font-size: 0.875rem; }
.cc-sidebar-user .cc-email { color: var(--ax-muted); font-size: 0.75rem; }
.cc-sidebar-user .cc-logout { color: var(--ax-muted); }
.cc-sidebar-user .cc-logout:hover { color: var(--ax-ink); background: var(--ax-hover); }

/* Cards */
.card, .stat-card {
  background: var(--ax-bg-card); border: 1px solid var(--ax-border);
  border-radius: var(--radius-lg); padding: 16px;
}
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--ax-ink); }
.stat-label { font-size: 0.75rem; color: var(--ax-muted); margin-top: 4px; }

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 24px; min-height: var(--touch-min);
  font-size: 0.875rem; font-weight: 500; border-radius: var(--radius);
  border: none; cursor: pointer; transition: 0.15s; text-decoration: none;
}
.btn-primary { background: var(--ax-accent); color: white; }
.btn-primary:hover { background: var(--ax-accent-2); }
.btn-secondary { background: var(--ax-bg-input); color: var(--ax-ink); border: 1px solid var(--ax-border); }
.btn-secondary:hover { background: var(--ax-hover); }
.btn-danger { background: var(--ax-red); color: white; }
.btn-danger:hover { background: #C0392B; }
.btn-success { background: var(--ax-green); color: white; }
.btn-success:hover { background: #0E9B6E; }
.btn-sm { padding: 10px 14px; min-height: 44px; font-size: 0.8125rem; }

/* Forms */
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 14px; min-height: var(--touch-min);
  background: var(--ax-bg-input); border: 1px solid var(--ax-border);
  border-radius: var(--radius); color: var(--ax-ink);
  font-size: 0.9375rem; -webkit-appearance: none; appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--ax-accent); box-shadow: 0 0 0 3px rgba(109,92,224,0.18);
}
@media screen and (max-width: 768px) {
  .form-input, .form-select, .form-textarea { font-size: 16px; }
}
/* Select dropdown list (dark theme) — fixes white-background / invisible-text bug */
select.form-select option {
  background: var(--ax-bg-input); color: var(--ax-ink);
}
select.form-select:focus option {
  background: var(--ax-bg-input); color: var(--ax-ink);
}
/* Multi-line form label */
.form-label {
  display: block; font-size: 0.8125rem; color: var(--ax-muted); margin-bottom: 6px; font-weight: 500;
}

/* Tables + mobile record cards */
.table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--ax-bg-card); border: 1px solid var(--ax-border); border-radius: var(--radius-lg); max-width: 100%; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; table-layout: auto; }
.data-table th { padding: 12px 16px; text-align: left; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; color: var(--ax-muted-2); white-space: nowrap; }
.data-table td { padding: 12px 16px; color: var(--ax-muted); }
.mobile-card-cell { display: none; }
.record-card { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 100%; background: var(--ax-bg-card); border: 1px solid var(--ax-border); border-radius: var(--radius-lg); padding: 14px; box-sizing: border-box; }
.record-card-head { min-width: 0; }
.record-title { color: var(--ax-ink); font-weight: 700; font-size: 0.98rem; line-height: 1.25; overflow-wrap: anywhere; }
.record-subtitle { color: var(--ax-muted); font-size: 0.82rem; line-height: 1.35; margin-top: 3px; overflow-wrap: anywhere; }
.record-card-status { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.record-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-width: 0; }
.record-card-grid div { min-width: 0; background: var(--ax-bg-input); border: 1px solid rgba(132,148,179,0.14); border-radius: var(--radius); padding: 9px 10px; }
.record-card-grid span { display: block; color: var(--ax-muted-2); font-size: 0.68rem; line-height: 1.1; text-transform: uppercase; font-weight: 700; margin-bottom: 4px; }
.record-card-grid strong { display: block; color: var(--ax-ink); font-size: 0.86rem; line-height: 1.25; font-weight: 600; overflow-wrap: anywhere; }
.record-card-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 2px; }
.project-card { min-height: 100%; }

/* Filters bar */
.filters-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; align-items: end; }
.filters-bar .form-input { min-width: 180px; flex: 1 1 auto; }
.filters-bar .form-select { min-width: 140px; flex: 0 0 auto; }

/* Modal overlay */
.modal-overlay { position: fixed; inset: 0; background: rgba(4,7,14,0.7); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px; }
.modal-content { background: var(--ax-bg-card); border: 1px solid var(--ax-border); border-radius: var(--radius-lg); width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; }
@media (max-width: 640px) {
  .modal-overlay { padding: 8px; align-items: flex-end; }
  .modal-content { max-width: 100%; margin: 0 4px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}
.modal-content form .grid { gap: 1rem; }
.modal-content .form-input, .modal-content .form-select { font-size: 0.9375rem; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 3px 12px; font-size: 0.75rem; font-weight: 500; border-radius: 9999px; }

/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--ax-bg-input) 0%, var(--ax-hover) 50%, var(--ax-bg-input) 100%); background-size: 200% 100%; animation: shimmer 1.5s ease-in-out infinite; border-radius: 4px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ═══ x-cloak — cache tout fragment Alpine avant hydratation ═══ */
[x-cloak] { display: none !important; }

/* Accessibilty */
:focus-visible { outline: 2px solid var(--ax-accent-2); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }



@media (max-width: 767px) {
  aside.-translate-x-full nav,
  aside.-translate-x-full .cc-sidebar-user { visibility: hidden; }
  aside.translate-x-0 nav,
  aside.translate-x-0 .cc-sidebar-user { visibility: visible; }
}

@media (max-width: 767px) {
  body { display: block !important; width: 100% !important; max-width: 100% !important; overflow-x: hidden !important; }
  body > aside { width: min(16rem, 86vw) !important; max-width: 86vw !important; }
  body > div.flex-1 { width: 100vw !important; max-width: 100vw !important; min-width: 0 !important; }
  .mobile-topbar, main { width: 100% !important; max-width: 100vw !important; box-sizing: border-box; }
}

/* Mobile overrides */
@media (max-width: 640px) {
  html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
  .mobile-topbar { min-height: 48px; }
  .mobile-menu-btn { min-width: 44px; min-height: 44px; }
  .mobile-topbar span { font-size: 0.95rem; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .filters-bar > * { width: 100%; max-width: 100%; flex: none; }

  .table-container { overflow-x: hidden; background: transparent; border: 0; border-radius: 0; }
  .data-table, .data-table tbody, .data-table tr { display: block; width: 100%; max-width: 100%; }
  .data-table thead, .data-table .desktop-cell { display: none !important; }
  .data-table tr { padding: 0; border: 0; margin: 0 0 12px; }
  .data-table .mobile-card-cell { display: block; padding: 0; width: 100%; max-width: 100%; box-sizing: border-box; }
  .data-table .mobile-card-cell::before { content: none; }
  .record-card-grid { grid-template-columns: 1fr; }
  .record-card-actions .btn-secondary { width: 100%; min-height: 44px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 1.5rem; }
  .btn-primary, .btn-secondary, .btn-danger { width: 100%; justify-content: center; }
  .sidebar-link { padding: 12px 14px; font-size: 0.92rem; min-height: 42px; }
  main { padding: 10px !important; overflow-x: hidden; }

  .modal-overlay { padding: 8px; align-items: flex-end; }
  .modal-content { max-width: 100%; margin: 0 4px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}

@media (max-width: 480px) {
  .grid.grid-cols-2 { grid-template-columns: 1fr !important; }
  .grid.grid-cols-3 { grid-template-columns: 1fr !important; }

  .record-card { padding: 12px; gap: 10px; }
  .record-title { font-size: 0.94rem; }
  .record-card-grid strong { font-size: 0.82rem; }

  .kanban-board .flex { flex-direction: column !important; }
  .kanban-column { width: 100% !important; min-width: 0 !important; max-width: 100% !important; }

  .modal-content { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-width: 95vw; }
  .btn-primary, .btn-secondary, .btn-danger { width: 100%; justify-content: center; min-height: 48px; padding: 12px 16px; }

  .filters-bar .form-input { min-width: 100%; flex: 1 1 100%; }
  main { padding: 8px !important; }
  .table-container { border-radius: var(--radius); }
}

@media (min-width: 481px) and (max-width: 640px) {
  .record-card { padding: 13px; }
  .btn-primary, .btn-secondary, .btn-danger { width: 100%; justify-content: center; min-height: 48px; }
}

/* Status badges — charte APEXIA (vert=succès, orange=attention, rouge=erreur, bleu/violet=neutre) */
.status-ACTIVE, .status-PAID, .status-DONE, .status-DELIVERED, .status-WON { background: rgba(16,185,129,0.14); color: var(--ax-green); }
.status-INACTIVE { background: var(--ax-hover); color: var(--ax-muted); }
.status-ERROR, .status-OVERDUE, .status-LOST { background: rgba(239,68,68,0.14); color: var(--ax-red); }
.status-SENT { background: rgba(139,92,246,0.14); color: var(--ax-accent-2); }
.status-DRAFT, .status-PLANNED { background: rgba(59,130,246,0.14); color: var(--ax-blue); }
.status-IN_PROGRESS { background: rgba(139,92,246,0.14); color: var(--ax-accent-2); }
.status-HIGH, .status-CRITICAL { background: rgba(239,68,68,0.14); color: var(--ax-red); }
.status-MEDIUM { background: rgba(245,158,11,0.16); color: var(--ax-orange); }
.status-LOW { background: var(--ax-hover); color: var(--ax-muted); }

/* ═══════════════════════════════════════════════════════════════════
   DASHBOARD — charte APEXIA UNIFIÉE (mêmes codes que Prospects/Clients)
   Réutilise exclusivement les tokens partagés (--ax-*) : aucune 2e charte.
   Layout synthétique conservé : max 5 lignes, liens "Voir tout",
   KPI cliquables, 2 colonnes desktop, responsive cartes mobile intact.
   ═══════════════════════════════════════════════════════════════════ */
.dash-wrap { max-width: 1440px; margin: 0 auto; min-width: 0; width: 100%; }

/* Bloc héro : panneau navy identique aux cards, boutons de la charte */
.dash-hero {
  background: var(--ax-bg-card); border: 1px solid var(--ax-border);
  border-radius: var(--radius-lg); padding: 24px 28px;
  min-width: 0; width: 100%; max-width: 100%; box-sizing: border-box;
}
.dash-hero h1 { font-weight: 800; font-size: 1.5rem; margin: 0; overflow-wrap: anywhere; }
.dash-hero h1, .dash-hero p { color: var(--ax-ink); }
.dash-hero p { color: var(--ax-muted); margin: 4px 0 0; font-size: 0.95rem; overflow-wrap: anywhere; }
.dash-title { font-size: 1.25rem; font-weight: 700; color: var(--ax-ink); }

/* Statut "Live / lecture seule" : badge de la charte (translucide, texte clair) */
.pill { display: inline-flex; align-items: center; gap: 8px; background: var(--ax-hover); border: 1px solid var(--ax-border); padding: 6px 14px; border-radius: 999px; font-size: 0.8rem; color: var(--ax-muted); }
.pill .dot { width: 8px; height: 8px; border-radius: 999px; background: var(--ax-green); display: inline-block; }

/* Retour APEXIA Control Center — bouton de la charte (bleu/violet foncé, texte blanc) */
.cc-return { display: inline-flex; align-items: center; gap: 8px; background: linear-gradient(135deg, #1E1B4B 0%, #4C1D95 100%); border: 1px solid #8B5CF6; color: #FFF; padding: 8px 16px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; text-decoration: none; flex: none; }
.cc-return:hover { background: linear-gradient(135deg, #312E81 0%, #5B21B6 100%); border-color: #A78BFA; color: #FFF; }
.cc-return:focus-visible { outline: 3px solid #A78BFA; outline-offset: 2px; color: #FFF; }

/* KPI — cards navy identiques aux stat-cards Prospects */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.kpi { background: var(--ax-bg-card); border: 1px solid var(--ax-border); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: 0 1px 3px rgba(4,7,14,0.5); min-width: 0; width: 100%; box-sizing: border-box; }
.kpi .v { font-size: 1.7rem; font-weight: 800; color: var(--ax-ink); line-height: 1.2; overflow-wrap: anywhere; }
.kpi .l { font-size: 0.78rem; color: var(--ax-muted); margin-top: 2px; font-weight: 500; overflow-wrap: anywhere; }
.kpi .sub { font-size: 0.72rem; color: var(--ax-muted-2); margin-top: 4px; }
.kpi.accent { border-top: 3px solid var(--ax-accent); }
.kpi.money .v { color: var(--ax-green); }
.kpi.clickable { cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .05s; }
.kpi.clickable:hover { border-color: var(--ax-accent); box-shadow: 0 3px 12px rgba(109,92,224,0.2); }
.kpi.clickable:focus-visible { outline: 3px solid var(--ax-accent-2); outline-offset: 2px; }
.kpi.clickable:active { transform: translateY(1px); }

/* Grille 2 colonnes desktop -> 1 colonne < 900px (synthétique, non pleine page) */
.section-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; min-width: 0; }
.section-grid .full { grid-column: 1 / -1; }
.section-grid > * { min-width: 0; overflow-wrap: anywhere; }
.card2 { background: var(--ax-bg-card); border: 1px solid var(--ax-border); border-radius: var(--radius-lg); padding: 18px 20px; overflow-wrap: anywhere; min-width: 0; }
.card2 h2, .card2 .dash-title { font-size: 1.05rem; font-weight: 700; color: var(--ax-ink); margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.card2 .chip { margin-left: auto; background: var(--ax-accent); color: #FFF; font-size: 0.7rem; padding: 3px 10px; border-radius: 999px; font-weight: 600; }
@media (max-width: 900px) { .section-grid { grid-template-columns: 1fr; } }

/* Tableaux Dashboard — mêmes containers/tables que les pages CRM
   .table-container (bordure/radius/scroll) + .data-table (mêmes styles +
   carte mobile @640px partagée). Les JS émettent data-label sur chaque td. */
.dashboard-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.dashboard-table th { text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ax-muted-2); padding: 8px 8px; border-bottom: 1px solid var(--ax-border); white-space: nowrap; }
.dashboard-table td { padding: 9px 8px; border-bottom: 1px solid var(--ax-border); color: var(--ax-ink); vertical-align: top; }
.dashboard-table tr:hover td { background: var(--ax-hover); }
.dashboard-table td::before { content: attr(data-label); }
/* Sur <640px les tableaux Dashboard utilisent la transform .data-table
   (thead masqué + cards) — cohérent avec toutes les pages CRM. */
@media (max-width: 640px) {
  .table-container.dash { padding: 12px; }
  .table-container.dash table.data-table { width: 100%; }
  .table-container.dash table.data-table thead { display: none; }
  .table-container.dash table.data-table tr { display: block; padding: 12px; border: 1px solid var(--ax-border); border-radius: 10px; margin-bottom: 10px; }
  .table-container.dash table.data-table td { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 5px 0; border: none; font-size: 0.82rem; min-width: 0; }
  .table-container.dash table.data-table td::before { content: attr(data-label); font-size: 0.7rem; font-weight: 700; color: #7a8fae; text-transform: uppercase; flex: none; padding-right: 14px; letter-spacing: .02em; }
  .table-container.dash table.data-table td .muted, .table-container.dash table.data-table td b { overflow-wrap: anywhere; }
}
/* KPI dashboard mobile : 1 colonne dès 520px pour éviter le scroll */
@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr !important; gap: 10px !important; }
  .kpi { padding: 13px 14px !important; }
  .kpi .v { font-size: 1.45rem !important; }
  .dash-hero { padding: 16px 14px !important; }
  .dash-hero h1 { font-size: 1.25rem !important; }
  .card2 { padding: 14px 14px !important; }
}
@media (min-width: 521px) and (max-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .dash-hero { padding: 18px 18px !important; }
}

/* Tags statut Dashboard — sémantiqe charte (vert/orange/rouge/bleu/violet) */
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; white-space: nowrap; }
.tag.sent { background: rgba(59,130,246,0.14); color: var(--ax-blue); }
.tag.draft, .tag.prep { background: var(--ax-hover); color: var(--ax-muted); }
.tag.accepted, .tag.active, .tag.client { background: rgba(16,185,129,0.14); color: var(--ax-green); }
.tag.declined, .tag.lost { background: rgba(239,68,68,0.14); color: var(--ax-red); }
.tag.follow, .tag.medium { background: rgba(245,158,11,0.16); color: var(--ax-orange); }
.tag.contacted, .tag.new { background: rgba(59,130,246,0.14); color: var(--ax-blue); }
.tag.qualified { background: rgba(16,185,129,0.14); color: var(--ax-green); }

.muted { color: var(--ax-muted-2); }
.mono { font-variant-numeric: tabular-nums; }
.empty { color: #9aabc3; text-align: center; padding: 18px 0; font-size: 0.85rem; }

/* Activité récente */
.act-item { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--ax-border); font-size: 0.85rem; color: var(--ax-ink); }
.act-item:last-child { border-bottom: none; }
.act-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--ax-accent); margin-top: 5px; flex: none; }

/* Prochaines actions */
.na-row { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; min-width: 0; }
.na-row .na-body { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.na-row .na-label { overflow-wrap: anywhere; }
.na-row .na-sub { color: var(--ax-muted); font-size: 0.75rem; overflow-wrap: anywhere; }

/* Liens "Voir tout" — couleur info charte */
.view-all { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; color: var(--ax-blue); font-weight: 600; font-size: 0.85rem; text-decoration: none; padding: 6px 0; }
.view-all:hover { text-decoration: underline; color: var(--ax-accent-2); }

/* Erreur — charte rouge */
.err-banner { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.4); color: var(--ax-red); border-radius: 10px; padding: 10px 14px; font-size: 0.85rem; margin-bottom: 14px; }