/* ============================================================
   TABLEAU HTML NATIF — Style CCIMA
   À ajouter dans static/css/ccima.css
   ============================================================ */

/* ── Conteneur responsive ── */
.ccima-table-wrapper {
  overflow-x: auto;
  margin-bottom: var(--spacing-lg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-card);
}

/* ── Tableau de base ── */
.ccima-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  font-size: 1.4rem;
  line-height: 1.5;
}

/* ── En-tête ── */
.ccima-table thead {
  background: var(--color-primary);
  color: #fff;
}

.ccima-table thead th {
  padding: 1.2rem 1.5rem;
  text-align: left;
  font-weight: var(--font-weight-semi-bold);
  white-space: nowrap;
  border-bottom: 2px solid var(--color-accent);
}

/* ── Corps ── */
.ccima-table tbody td,
.ccima-table tbody th {
  padding: 1rem 1.5rem;
  text-align: left;
  border-bottom: 1px solid var(--color-outline);
  vertical-align: top;
  color: var(--color-on-surface);
}

/* ── En-têtes de ligne (première colonne) ── */
.ccima-table tbody th[scope="row"] {
  background: var(--color-surface-dim);
  color: var(--color-primary);
  font-weight: var(--font-weight-semi-bold);
  width: 25%;
  border-bottom: 1px solid var(--color-outline-variant);
}

/* ── Alternance de lignes ── */
.ccima-table tbody tr:nth-child(even) td {
  background: rgba(247, 247, 248, 0.5);
}

.ccima-table tbody tr:hover td,
.ccima-table tbody tr:hover th[scope="row"] {
  background: var(--color-surface-dim);
  transition: background var(--transition);
}

/* ── Dernière ligne sans bordure ── */
.ccima-table tbody tr:last-child td,
.ccima-table tbody tr:last-child th {
  border-bottom: none;
}

/* ── Accent sur la première colonne ── */
.ccima-table tbody td:first-child {
  font-weight: var(--font-weight-semi-bold);
  color: var(--color-primary);
}

/* ── Cellules vides ── */
.ccima-table td:empty,
.ccima-table th:empty {
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(0, 0, 0, 0.03) 10px,
    rgba(0, 0, 0, 0.03) 20px
  );
  color: var(--color-secondary);
  font-style: italic;
}

.ccima-table td:empty::before,
.ccima-table th:empty::before {
  content: "—";
  color: var(--color-secondary);
  opacity: 0.5;
}

/* ── Lignes avec statut (succès/erreur) ── */
.ccima-table tbody tr.ccima-row-success td {
  background: rgba(40, 167, 69, 0.08);
  border-left: 3px solid var(--color-success);
}

.ccima-table tbody tr.ccima-row-error td {
  background: rgba(220, 53, 69, 0.08);
  border-left: 3px solid var(--color-error);
}

.ccima-table tbody tr.ccima-row-accent td {
  border-left: 3px solid var(--color-accent);
}

/* ── Pied de tableau ── */
.ccima-table tfoot {
  background: var(--color-surface-dim);
  font-weight: var(--font-weight-semi-bold);
}

.ccima-table tfoot td,
.ccima-table tfoot th {
  padding: 1rem 1.5rem;
  border-top: 2px solid var(--color-primary);
  color: var(--color-primary);
}

/* ── Légende ── */
.ccima-table caption {
  caption-side: top;
  padding: var(--spacing-sm) 0;
  font-weight: var(--font-weight-semi-bold);
  color: var(--color-primary);
  text-align: left;
  font-size: 1.6rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .ccima-table-wrapper {
    border-radius: 0;
    margin-left: calc(-1 * var(--container-padding));
    margin-right: calc(-1 * var(--container-padding));
    width: calc(100% + (var(--container-padding) * 2));
  }

  .ccima-table {
    font-size: 1.3rem;
  }

  .ccima-table thead th,
  .ccima-table tbody td,
  .ccima-table tbody th {
    padding: 0.8rem 1rem;
  }

  .ccima-table tbody th[scope="row"] {
    width: 35%;
  }
}
