/* =========================
   FLOWMATIQUE DASHBOARD
   dash.css — v2 Professional
   Direction : Utilitarian Premium
========================= */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  /* ——— Backgrounds ——— */
  --bg:           #eef1f5;
  --surface:      #ffffff;
  --surface-soft: #f6f8fb;
  --surface-hover:#edf1f7;

  /* ——— Text ——— */
  --text:         #0c1929;
  --text-soft:    #3a4f66;
  --text-muted:   #637487;

  /* ——— Borders ——— */
  --border:       #d6dde8;
  --border-strong:#b3bfcf;

  /* ——— Brand : bleu nuit ——— */
  --brand:        #14305e;
  --brand-mid:    #1d4480;
  --brand-light:  #2a5ea8;
  --brand-soft:   rgba(20, 48, 94, 0.07);
  --brand-accent: #2563eb;   /* filet d'accentuation uniquement */

  /* ——— Statuts métier ——— */
  --success:      #146c34;
  --success-soft: rgba(20, 108, 52, 0.09);
  --success-border:rgba(20, 108, 52, 0.22);

  --warning:      #b84c00;
  --warning-soft: rgba(184, 76, 0, 0.09);
  --warning-border:rgba(184, 76, 0, 0.22);

  --danger:       #b91c1c;
  --danger-soft:  rgba(185, 28, 28, 0.09);
  --danger-border:rgba(185, 28, 28, 0.20);

  /* ——— Ombres chirurgicales ——— */
  --shadow-xs: 0 1px 3px rgba(12, 25, 41, 0.08);
  --shadow-sm: 0 2px 8px rgba(12, 25, 41, 0.09);
  --shadow-md: 0 4px 16px rgba(12, 25, 41, 0.10);

  /* ——— Géométrie — angles sobres ——— */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;

  --container:  1280px;
  --header-h:   68px;
}

/* =========================
   RESET
========================= */

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'IBM Plex Sans', ui-sans-serif, system-ui, sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(20,48,94,0.028) 0%, transparent 320px),
    var(--bg);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }

button, input, select, textarea { font: inherit; }

a { color: inherit; text-decoration: none; }

/* =========================
   HEADER
========================= */

.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 36px;
  background: #fff;
  border-bottom: 1.5px solid var(--border);
  box-shadow: 0 1px 0 rgba(12,25,41,0.04);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.logo {
  height: 36px !important;
  width: auto !important;
  object-fit: contain;
}

/* séparateur vertical */
.header-left::after {
  content: '';
  display: block;
  width: 1.5px;
  height: 28px;
  background: var(--border);
  margin-left: 4px;
}

.company {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 4px;
}

.company .label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

#company-name {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* =========================
   ACCOUNT MENU
========================= */

.account-wrapper {
  position: relative;
  margin-left: auto;
}

.account-trigger {
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.account-trigger:hover {
  border-color: var(--brand-light);
  background: var(--surface-soft);
  box-shadow: var(--shadow-sm);
}

.avatar,
.avatar-big {
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background: var(--brand);
  border-radius: var(--radius-sm);
  user-select: none;
  letter-spacing: 0.02em;
}

.avatar {
  width: 30px;
  height: 30px;
  font-size: 0.82rem;
}

.avatar-big {
  width: 46px;
  height: 46px;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
}

.account-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 272px;
  padding: 8px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}

.account-wrapper.open .account-menu,
.account-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.account-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 14px;
}

.identity-text { min-width: 0; }

.identity-text .name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.identity-text .email {
  margin-top: 2px;
  font-size: 0.82rem;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.divider {
  height: 1px;
  margin: 4px 0;
  background: var(--border);
}

.menu-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.90rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background 0.13s ease;
}

.menu-item:hover {
  background: var(--surface-soft);
}

.menu-item.danger {
  color: var(--danger);
}

.menu-item.danger:hover {
  background: var(--danger-soft);
}

/* =========================
   MAIN CONTAINER
========================= */

.container {
  width: min(calc(100% - 48px), var(--container));
  margin: 28px auto 0;
  padding-bottom: 48px;
}

/* =========================
   ANALYTICS / KPI
========================= */

.analytics {
  margin-bottom: 24px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px 26px;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* filet de marque à gauche — fin et précis */
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--brand);
  border-radius: 2px 0 0 2px;
}

.stat-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.stat-card .label {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  margin-bottom: 10px;
}

.stat-card .value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(1.9rem, 2.8vw, 2.4rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--brand);
  min-height: 38px;
  display: flex;
  align-items: center;
}

/* =========================
   ALERT BLOCK
========================= */

.alert-block {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 0.93rem;
  font-weight: 500;
  border: 1.5px solid transparent;
  line-height: 1.4;
}

.alert-block strong {
  font-weight: 700;
}

.alert-block.urgent {
  background: #fffaf5;
  border-color: var(--warning-border);
  color: #7a3000;
  box-shadow: var(--shadow-xs);
}

/* =========================
   GENERIC CARD
========================= */

.card {
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 26px 28px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  margin: 0;
  font-size: clamp(1.2rem, 1.7vw, 1.55rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
  font-weight: 700;
  color: var(--text);
}

.section-subtext {
  margin: 6px 0 0;
  max-width: 560px;
  color: var(--text-soft);
  font-size: 0.90rem;
  line-height: 1.5;
}

/* =========================
   FILTERS
========================= */

.leads-filters {
  display: flex;
  align-items: center;
  gap: 10px !important;
  margin-bottom: 16px !important;
  flex-wrap: wrap;
}

#lead-search,
#status-filter {
  height: 42px;
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

#lead-search {
  flex: 1 1 300px !important;
  padding: 0 14px !important;
  min-width: 220px;
}

#status-filter {
  min-width: 170px;
  padding: 0 12px !important;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23637487' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px !important;
}

#lead-search::placeholder {
  color: #8fa1b3;
  font-size: 0.88rem;
}

#lead-search:focus,
#status-filter:focus {
  outline: none;
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(20, 48, 94, 0.08);
  background: #fff;
}

/* =========================
   TABLE
========================= */

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  padding: 11px 14px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 14px 14px;
  font-size: 0.92rem;
  color: var(--text);
  border-bottom: 1px solid #e8eef5;
  vertical-align: middle;
}

tbody tr {
  transition: background 0.12s ease;
}

tbody tr:hover {
  background: var(--surface-soft);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody td:nth-child(1) { font-weight: 700; color: var(--brand); }
tbody td:nth-child(2),
tbody td:nth-child(3) { color: var(--text-soft); font-size: 0.88rem; }
tbody td:nth-child(4) { font-weight: 600; }

/* =========================
   STATUS BADGES
========================= */

.status-badge,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.status-new, .badge-new, .badge-neutral {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: rgba(20, 48, 94, 0.16);
}

.status-warm, .badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: var(--warning-border);
}

.status-pending {
  background: rgba(180, 130, 0, 0.09);
  color: #7a5500;
  border-color: rgba(180, 130, 0, 0.22);
}

.status-success, .badge-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: var(--success-border);
}

.status-danger, .badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
}

/* =========================
   ACTION BUTTONS TABLE
========================= */

td button,
.pagination button {
  appearance: none;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

td button {
  min-height: 34px;
  padding: 0 12px;
  margin-right: 6px;
  margin-top: 2px;
}

td button:last-child { margin-right: 0; }

td button:first-child {
  background: var(--success-soft);
  color: var(--success);
  border-color: var(--success-border);
}
td button:first-child:hover {
  background: rgba(20, 108, 52, 0.15);
}

td button:last-child {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
}
td button:last-child:hover {
  background: rgba(185, 28, 28, 0.14);
}

/* =========================
   PAGINATION
========================= */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.pagination button {
  width: 38px;
  height: 38px;
  background: #fff;
  color: var(--text-soft);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-size: 0.90rem;
  box-shadow: var(--shadow-xs);
}

.pagination button:hover:not(:disabled) {
  border-color: var(--brand-light);
  color: var(--brand);
  background: var(--brand-soft);
}

.pagination button:disabled {
  opacity: 0.40;
  cursor: not-allowed;
}

#page-indicator {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-soft);
  min-width: 90px;
  text-align: center;
  letter-spacing: 0.02em;
}

/* =========================
   FOOTER
========================= */

.dashboard-footer {
  margin-top: 40px;
  border-top: 1.5px solid var(--border);
  background: #fff;
}

.dashboard-footer-container {
  width: min(calc(100% - 48px), var(--container));
  margin: 0 auto;
  padding: 22px 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.footer-left { max-width: 480px; }

.footer-brand {
  margin: 0 0 4px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-soft);
}

.footer-subtext {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.83rem;
}

.footer-right {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 20px;
}

.footer-right a {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.84rem;
  transition: color 0.13s ease;
}

.footer-right a:hover {
  color: var(--brand);
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 1100px) {
  .stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 860px) {
  .stats {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 20px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 820px) {
  .top-bar {
    padding: 0 18px;
  }

  .container,
  .dashboard-footer-container {
    width: min(calc(100% - 24px), var(--container));
  }

  .header-left { gap: 14px; }

  .company .label { font-size: 0.68rem; }

  #company-name { font-size: 0.92rem; }

  .card {
    padding: 18px;
    border-radius: var(--radius-md);
  }

  .leads-filters {
    flex-direction: column;
    align-items: stretch;
  }

  #lead-search,
  #status-filter { width: 100%; }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  td button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 560px) {
  .top-bar {
    height: auto;
    min-height: var(--header-h);
    padding: 14px 18px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .header-left { flex: 1; min-width: 0; }

  .account-wrapper { align-self: center; }

  .account-menu {
    width: min(272px, calc(100vw - 24px));
    right: -4px;
  }

  .stat-card {
    padding: 18px 18px 16px 22px;
    border-radius: var(--radius-md);
  }

  .stat-card .value { font-size: 1.75rem; }

  .alert-block {
    padding: 12px 14px;
    font-size: 0.88rem;
  }

  .dashboard-footer-container {
    padding: 18px 0 22px;
  }

  .footer-right { justify-content: flex-start; }
}
