/**
 * Harmonisation dashboards ETS AAD
 * Référence visuelle : /rh/ — masthead clair, KPI cartes neutres + halos, modules, panels.
 * Préfixe : dash- (charger après design-system.css)
 */

/* —— Shell page —— */
.dash-shell {
  min-height: calc(100vh - var(--header-height, 56px));
  background: var(--bg-secondary);
  padding-bottom: 2rem;
}

/* —— Masthead —— */
.dash-masthead {
  padding: 1.5rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.dash-masthead-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 1.5rem;
}

.dash-masthead-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.dash-masthead h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.8vw, 1.875rem);
  font-weight: 700;
  color: var(--hl-blue);
  letter-spacing: -0.02em;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
}

.dash-masthead-inner > div:first-child {
  flex: 1 1 280px;
  min-width: 0;
  max-width: 100%;
}

.dash-chip-date {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--gray-100);
  border: 1px solid var(--border);
}

.dash-masthead-sub {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  max-width: 100%;
  line-height: 1.5;
  white-space: normal;
  overflow-wrap: break-word;
}

.dash-masthead-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.dash-btn-accent {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: var(--hl-orange);
  color: var(--white);
  text-decoration: none;
  transition: background 0.15s ease;
}

.dash-btn-accent:hover {
  background: var(--hl-orange-light);
  color: var(--white);
}

/* —— Corps —— */
.dash-body {
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(1rem, 2.5vw, 2rem);
}

.dash-eyebrow {
  margin: 0 0 0.75rem 0.125rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.dash-section-title {
  margin: 0 0 1rem 0.125rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--hl-blue);
  letter-spacing: -0.02em;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  white-space: normal;
  overflow-wrap: break-word;
  max-width: 100%;
}

/* —— KPI —— */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.dash-kpi {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 1.1rem 1.15rem 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease;
}

.dash-kpi:hover {
  box-shadow: var(--shadow-md);
}

.dash-kpi--featured {
  border-left: 3px solid var(--hl-orange);
  grid-column: span 2;
}

@media (max-width: 768px) {
  .dash-kpi--featured {
    grid-column: span 1;
  }
}

.dash-kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.dash-kpi-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  line-height: 1.35;
  max-width: 13rem;
}

.dash-kpi-icon {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.dash-kpi-icon--navy {
  background: var(--color-primary-light);
  color: var(--hl-blue);
}

.dash-kpi-icon--emerald {
  background: var(--success-light);
  color: var(--success-dark, #047857);
}

.dash-kpi-icon--slate {
  background: var(--gray-100);
  color: var(--gray-600);
}

.dash-kpi-icon--accent {
  background: rgba(234, 88, 12, 0.12);
  color: var(--hl-orange);
}

.dash-kpi-icon--amber {
  background: var(--warning-light);
  color: var(--warning-dark, #b45309);
}

.dash-kpi-val {
  font-size: clamp(1.5rem, 3.8vw, 1.875rem);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 0.35rem;
  word-break: break-word;
}

.dash-kpi-meta {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.4;
}

.dash-kpi-meta.-warn {
  color: var(--hl-orange);
}

/* Modules métier —— */
.dash-workspace {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (min-width: 1200px) {
  .dash-workspace {
    grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
    align-items: start;
  }
}

.dash-module-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
}

.dash-mod-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 1.25rem 1.35rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dash-mod-card:hover {
  border-color: var(--mod-hover, var(--hl-blue-accent));
  box-shadow: var(--shadow-md);
  color: inherit;
}

.dash-mod-card-head {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.dash-mod-icon-wrap {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
  background: var(--mod-bg, var(--gray-100));
  color: var(--mod-fg, var(--hl-blue-dark));
}

.dash-mod-card h3 {
  margin: 0 0 0.35rem 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.dash-mod-desc {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.dash-mod-foot {
  margin-top: auto;
  padding-top: 1rem;
  padding-left: 0.125rem;
  padding-right: 0.125rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--mod-fg, var(--hl-blue));
}

.dash-mod-foot i {
  opacity: 0.45;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.dash-mod-card:hover .dash-mod-foot i {
  opacity: 1;
  transform: translateX(3px);
}

.dash-mod--navy {
  --mod-bg: rgba(12, 79, 115, 0.08);
  --mod-fg: var(--hl-blue);
  --mod-hover: var(--hl-blue-accent);
}

.dash-mod--sea {
  --mod-bg: var(--success-light);
  --mod-fg: var(--success);
  --mod-hover: var(--success);
}

.dash-mod--violet {
  --mod-bg: #f5f3ff;
  --mod-fg: #6d28d9;
  --mod-hover: #8b5cf6;
}

.dash-mod--orange {
  --mod-bg: rgba(251, 146, 60, 0.15);
  --mod-fg: var(--hl-orange);
  --mod-hover: var(--hl-orange);
}

.dash-mod--rose {
  --mod-bg: var(--danger-light);
  --mod-fg: var(--danger);
  --mod-hover: var(--danger);
}

.dash-sp-section + .dash-sp-section {
  margin-top: 2rem;
}

.dash-panel-aside-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.dash-panel-aside-title a {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--hl-blue);
  text-decoration: none;
}

.dash-panel-aside-title a:hover {
  color: var(--hl-orange);
}

.dash-watch-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.dash-watch-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background 0.12s ease;
}

.dash-watch-item:last-child {
  border-bottom: none;
}

.dash-watch-item:hover {
  background: var(--gray-50);
  color: inherit;
}

.dash-watch-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  margin-top: 0.35rem;
  flex-shrink: 0;
  background: var(--hl-orange);
}

.dash-watch-dot.-muted {
  background: var(--gray-400);
}

.dash-watch-copy strong {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
  line-height: 1.3;
}

.dash-watch-copy span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Panels & tableaux (usage dans modules RH / rapports dashboards) —— */
.dash-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.dash-panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
  background: var(--gray-50);
}

.dash-panel-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--hl-blue);
  white-space: normal;
  overflow-wrap: break-word;
  max-width: 100%;
  flex: 1 1 auto;
  min-width: 0;
}

.dash-panel-body {
  padding: 0;
  overflow-x: auto;
}

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

.dash-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.dash-table tbody td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--text-secondary);
  vertical-align: middle;
}

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

.dash-table tbody tr:hover {
  background: var(--gray-50);
}

.dash-tag {
  display: inline-flex;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.dash-tag--info {
  background: var(--gray-100);
  color: var(--hl-blue);
  border-color: var(--gray-200);
}

.dash-tag--ok {
  background: var(--success-light);
  color: var(--success-dark, #065f46);
  border-color: rgba(5, 150, 105, 0.25);
}

/* Cartes graphiques / tableaux génériques (promotion / forecast) */
.dash-surface-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg, 1.25rem);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.dash-chart-wrap {
  position: relative;
  height: 360px;
  margin-top: 0.5rem;
}

@media (max-width: 1024px) {
  .dash-masthead-inner {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

@media (max-width: 768px) {
  .dash-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dash-module-grid {
    grid-template-columns: 1fr;
  }

  .dash-shell .dash-table thead {
    display: none;
  }

  .dash-shell .dash-panel-body .dash-table tbody,
  .dash-shell .dash-panel-body .dash-table tr {
    display: block;
  }

  .dash-shell .dash-panel-body .dash-table tr {
    margin-bottom: 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.65rem;
    background: var(--bg-card);
  }

  .dash-shell .dash-panel-body .dash-table td {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.45rem 0;
    border: none;
    border-bottom: 1px solid var(--gray-100);
  }

  .dash-shell .dash-panel-body .dash-table td:last-child {
    border-bottom: none;
  }

  .dash-shell .dash-panel-body .dash-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
  }

  .dash-masthead-actions .btn-hl,
  .dash-btn-accent {
    flex: 1 1 auto;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .dash-kpi-grid {
    grid-template-columns: 1fr;
  }

  .dash-masthead-inner {
    flex-direction: column;
    align-items: stretch;
  }
}
