* {
  box-sizing: border-box;
}

/* Le corps, les couleurs, les polices et le layout général sont gérés par
   "../CHU - Liste publis mensuelles/styles.css". Ici on ne définit que les
   ajustements spécifiques à l'analyseur SIGAPS. */

/* Conteneur principal (hérite de .container du thème global) */

main.container {
  margin-top: 1.5rem;
  margin-bottom: 2rem;
  font-size: 0.95rem; /* Légèrement plus grand que le thème global */
}

.card {
  background: var(--surface-color, #ffffff);
  border-radius: 8px;
  padding: 1.4rem 1.7rem 1.7rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-md, 0 1px 3px rgba(15, 23, 42, 0.12));
  border: 1px solid var(--border-color, #e5e7eb);
}

.card h2 {
  margin-top: 0;
}

label {
  font-size: 0.95rem;
}

input[type='file'],
select,
button {
  font-family: inherit;
}

input[type='file'] {
  margin: 0.5rem 0 1rem;
}

button {
  border-radius: 4px;
  border: 1px solid var(--primary-color, #2563eb);
  background: var(--primary-color, #2563eb);
  color: #fff;
  padding: 0.35rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

button:hover:not([disabled]) {
  background: var(--primary-hover, #1d4ed8);
}

button.secondary {
  border-color: #9ca3af;
  background: #fff;
  color: #111827;
}

button.secondary:hover:not([disabled]) {
  background: #f3f4f6;
}

.muted {
  color: #6b7280;
}

.small {
  font-size: 0.8rem;
}

/* Footer personnalisé */

.app-footer {
  border-top: 1px solid #111827;
  background: #020617; /* gris très foncé / quasi noir pour bien contraster */
  color: #e5e7eb;
}

.app-footer-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 1.5rem 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: space-between;
}

.app-footer-section h2,
.app-footer-section h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.app-footer-section p {
  margin: 0;
  font-size: 0.85rem;
}

.app-footer-section h2,
.app-footer-section h3,
.app-footer-section p,
.app-footer-bottom {
  color: #e5e7eb;
}

.app-footer-bottom {
  border-top: 1px solid #111827;
  padding: 0.4rem 1.5rem 0.7rem;
  text-align: center;
}

/* Header actions */

.app-header {
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-header-inner {
  display: grid;
  align-items: center;
  width: 100%;
  gap: 0.75rem;
}

.app-header-main {
  text-align: center;
}

.app-header-main h1 {
  margin-bottom: 0.15rem;
}

.app-header-main p {
  margin: 0;
}

.app-header-actions {
  display: flex;
  align-items: center;
}

.app-header-actions-left {
  justify-content: flex-start;
}

.app-header-actions-right {
  justify-content: flex-end;
}

.app-header-actions button {
  white-space: nowrap;
}

/* Utilitaire pour masquer des sections */

.hidden {
  display: none;
}

/* Étape d'intro */

.intro-steps {
  margin: 0.5rem 0 1rem;
  padding-left: 1.2rem;
}

/* Étape d'import : sélection du mode + zones d'import */

.import-mode {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.import-mode label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.import-panel {
  margin-top: 1rem;
}

.multi-import-panel {
  margin-top: 1rem;
}

.multi-import-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.multi-import-step h3 {
  margin-top: 0;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

.multi-import-actions {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.file-drop {
  border: 2px dashed var(--primary-color, #2563eb);
  border-radius: 8px;
  padding: 1.25rem 1rem;
  background: #eff6ff;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.file-drop:hover {
  background: #dbeafe;
  border-color: var(--primary-hover, #1d4ed8);
  box-shadow: var(--shadow-md, 0 1px 3px rgba(15, 23, 42, 0.16));
}

.file-drop-icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: #dbeafe;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-color, #2563eb);
  font-size: 1.4rem;
}

.file-drop-title {
  font-weight: 600;
  display: block;
}

.file-drop-subtitle {
  display: block;
  font-size: 0.85rem;
  color: #4b5563;
}

.import-panel #fileInfo {
  margin-top: 0.5rem;
}

/* Onglets multi-fichiers */

.dataset-tabs {
  margin-bottom: 1rem;
}

.dataset-tabs-label {
  margin-bottom: 0.35rem;
}

.dataset-tabs-label strong {
  font-weight: 600;
}

.dataset-tabs-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color, #d1d5db);
}

.dataset-tab {
  border-radius: 6px 6px 0 0;
  padding: 0.4rem 0.8rem 0.3rem;
  border: 2px solid transparent;
  border-bottom-width: 2px;
  background: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  font-size: 0.85rem;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  min-width: 0;
  color: #111827;
  transition: border-color 0.15s ease, box-shadow 0.15s ease,
    background-color 0.15s ease, opacity 0.15s ease;
}

.dataset-tab-badge {
  background: #e5e7eb;
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
}

.dataset-tab-label {
  font-weight: 500;
  font-size: 0.8rem;
}

.dataset-tab-status {
  font-size: 0.7rem;
  color: #6b7280;
}

/* Onglet non mappé : contour rouge bien visible */
.dataset-tab.unmapped {
  border-color: #fecaca; /* rouge clair par défaut */
}

.dataset-tab.unmapped .dataset-tab-status {
  color: #b91c1c;
}

/* Onglet mappé : contour vert bien visible */
.dataset-tab.mapped {
  border-color: #bbf7d0; /* vert clair par défaut */
}

.dataset-tab.mapped .dataset-tab-status {
  color: #15803d;
}

/* Onglet global (toutes les données) */
.dataset-tab.global-tab {
  font-weight: 600;
}

.dataset-tab.global-tab .dataset-tab-badge {
  background: #0f766e;
  color: #ecfeff;
}

.dataset-tab.global-tab.unmapped {
  border-color: #e5e7eb;
}

.dataset-tab.global-tab.mapped {
  border-color: #0f766e;
}

/* Onglets non actifs : texte légèrement atténué mais lisible */
.dataset-tab:not(.active) {
  opacity: 0.85;
}

/* Onglet actif + non mappé : rouge plus franc + fond léger */
.dataset-tab.active.unmapped {
  border-color: #dc2626;
  background: #fef2f2;
  opacity: 1;
}

/* Onglet actif + mappé : vert plus franc + fond léger */
.dataset-tab.active.mapped {
  border-color: #16a34a;
  background: #ecfdf3;
  opacity: 1;
}

/* Style générique pour l'onglet actif (sans toucher à la couleur de bordure) */
.dataset-tab.active {
  color: #111827;
}

.dataset-tab.active .dataset-tab-badge {
  background: currentColor;
  color: #fff;
}

/* Tableau d'aperçu (supprimé de l'interface principale, classes conservées si besoin ailleurs) */

.table-wrapper {
  max-height: 260px;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #fff;
}

.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table-wrapper th,
.table-wrapper td {
  border: 1px solid #e5e7eb;
  padding: 0.3rem 0.45rem;
  text-align: left;
}

.table-wrapper thead {
  background: #f3f4f6;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table-wrapper thead th {
  font-weight: 600;
  font-size: 0.8rem;
  color: #374151;
}

.table-wrapper tbody tr:nth-child(even) {
  background: #f9fafb;
}

.table-wrapper tbody tr:hover {
  background: #e5f0ff;
}

.table-wrapper td {
  max-width: 260px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Les tableaux de stats doivent laisser respirer le contenu (pas de coupure en largeur)
   et ne pas scroller en interne (on laisse scroller toute la page). */
.stats-section .table-wrapper {
  max-height: none;
  overflow-y: visible;
}

.stats-section .table-wrapper td,
.stats-section .table-wrapper th {
  max-width: none;
  white-space: normal;
  text-overflow: clip;
}


/* Mapping */

.mapping-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.mapping-container {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.mapping-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem 0.75rem;
  align-items: center;
}

.mapping-row label {
  font-weight: 500;
}

.mapping-row label,
.mapping-row select,
.mapping-row .mapping-example {
  margin-bottom: 0.15rem;
}

.mapping-row select {
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  font-size: 0.9rem;
}

.mapping-example {
  font-size: 0.8rem;
  color: #4b5563;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mapping-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  gap: 0.75rem;
}

/* Graphiques */

#charts {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.chart-card {
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
  padding: 0.75rem 0.75rem 0.5rem;
  background: var(--surface-color, #f9fafb);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(15, 23, 42, 0.08));
}

.chart-card h3 {
  margin-top: 0;
  font-size: 1rem;
}

/* Actions du tableau de bord (export, etc.) */
.dashboard-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.dashboard-actions button {
  font-size: 0.85rem;
}

/* Stats tables */

.stats-section {
  margin-top: 1.25rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.stats-card {
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
  padding: 0.75rem 0.75rem 0.5rem;
  background: var(--surface-color, #f9fafb);
  box-shadow: var(--shadow-sm, 0 1px 2px rgba(15, 23, 42, 0.08));
}

.stats-card h3 {
  margin-top: 0;
  font-size: 1rem;
}

.small-table {
  max-height: 220px;
}

.mini-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8rem;
}

.mini-table th,
.mini-table td {
  padding: 0.3rem 0.55rem;
}

.mini-table thead th {
  background: #e5e7eb;
  font-weight: 600;
  border-bottom: 1px solid #d1d5db;
}

.mini-table tbody tr:nth-child(even) {
  background: #f9fafb;
}

.mini-table tbody tr:hover {
  background: #e5f0ff;
}

.mini-table tfoot td {
  font-weight: 600;
  border-top: 1px solid #d1d5db;
}

.mini-table th.num,
.mini-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 700px) {
  header {
    padding: 1rem 1rem 1.25rem;
  }

  .app-header-inner {
    grid-template-columns: auto 1fr;
    row-gap: 0.5rem;
  }

  .app-header-main {
    grid-column: 1 / -1;
    text-align: left;
  }

  .stats-section {
    grid-template-columns: 1fr;
  }

  main {
    padding: 0 0.75rem 2rem;
  }

  .mapping-row {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .mapping-example {
    white-space: normal;
  }

  .file-drop {
    flex-direction: column;
    align-items: flex-start;
  }

  .dataset-tabs-list {
    gap: 0.35rem;
    grid-template-columns: 1fr;
  }

  .multi-import-steps {
    grid-template-columns: 1fr;
  }
}
