/**
 * Styles for core/table block
 * Background colors and automatic text color adjustments
 */

/* Base styles for table */
.wp-block-table {
  margin-bottom: var(
    --wp--custom--semantic--spacing--300,
    var(--wp--custom--primitive--spacing--24, 24px)
  );
}

.wp-block-table table {
  border-collapse: collapse;
  /* Bordure extérieure du tableau */
  border-width: var(
    --wp--custom--semantic--border--width--default,
    var(--wp--custom--primitive--size--1, 1px)
  );
  border-style: solid;
  border-color: var(
    --wp--custom--semantic--color--border--secondary,
    var(--wp--custom--primitive--color--neutral--300, #d7d7d7)
  );
}

figure.wp-block-table table th,
figure.wp-block-table table td,
.wp-block-table table th,
.wp-block-table table td,
.wp-block-table th,
.wp-block-table td {
  padding: var(
    --wp--custom--semantic--spacing--200,
    var(--wp--custom--primitive--spacing--16, 16px)
  );
  font-size: var(
    --wp--custom--semantic--font--default--base--font-size,
    var(--wp--custom--primitive--font--size--400, 16px)
  );
  color: var(
    --wp--custom--semantic--color--text--primary,
    var(--wp--custom--primitive--color--neutral--900, #121212)
  );
  /* Bordures intérieures des cellules */
  border-width: var(
    --wp--custom--semantic--border--width--default,
    var(--wp--custom--primitive--size--1, 1px)
  );
  border-style: solid;
  border-color: var(
    --wp--custom--semantic--color--border--secondary,
    var(--wp--custom--primitive--color--neutral--300, #d7d7d7)
  );
}

.wp-block-table th {
  text-align: left;
  font-weight: var(--wp--custom--primitive--font--weight--800, Heavy);
}

.wp-block-table td {
  font-weight: var(--wp--custom--primitive--font--weight--400, Roman);
}

/* Neutraliser les classes has-text-color pour permettre l'adaptation automatique */
table.has-background th.has-text-color,
table.has-background td.has-text-color {
  color: inherit !important;
}

/* Automatic text colors based on background - Surface colors */
/* Backgrounds sombres - texte clair */
/* La classe de couleur est sur l'élément <table> */
figure.wp-block-table table.has-surface-brand-background-color,
figure.wp-block-table table.has-surface-brand-background-color *,
table.has-surface-brand-background-color,
table.has-surface-brand-background-color *,
figure.wp-block-table table.has-surface-brand-background-color th,
figure.wp-block-table table.has-surface-brand-background-color td,
figure.wp-block-table table.has-surface-brand-background-color a,
table.has-surface-brand-background-color th,
table.has-surface-brand-background-color td,
table.has-surface-brand-background-color a,
figure.wp-block-table table.has-surface-inverse-background-color,
figure.wp-block-table table.has-surface-inverse-background-color *,
table.has-surface-inverse-background-color,
table.has-surface-inverse-background-color *,
figure.wp-block-table table.has-surface-inverse-background-color th,
figure.wp-block-table table.has-surface-inverse-background-color td,
figure.wp-block-table table.has-surface-inverse-background-color a,
table.has-surface-inverse-background-color th,
table.has-surface-inverse-background-color td,
table.has-surface-inverse-background-color a,
figure.wp-block-table table.has-surface-accent-dark-background-color,
figure.wp-block-table table.has-surface-accent-dark-background-color *,
table.has-surface-accent-dark-background-color,
table.has-surface-accent-dark-background-color *,
figure.wp-block-table table.has-surface-accent-dark-background-color th,
figure.wp-block-table table.has-surface-accent-dark-background-color td,
figure.wp-block-table table.has-surface-accent-dark-background-color a,
table.has-surface-accent-dark-background-color th,
table.has-surface-accent-dark-background-color td,
table.has-surface-accent-dark-background-color a,
figure.wp-block-table table.has-surface-accent-darker-background-color,
figure.wp-block-table table.has-surface-accent-darker-background-color *,
table.has-surface-accent-darker-background-color,
table.has-surface-accent-darker-background-color *,
figure.wp-block-table table.has-surface-accent-darker-background-color th,
figure.wp-block-table table.has-surface-accent-darker-background-color td,
figure.wp-block-table table.has-surface-accent-darker-background-color a,
table.has-surface-accent-darker-background-color th,
table.has-surface-accent-darker-background-color td,
table.has-surface-accent-darker-background-color a,
.wp-block-table.has-surface-accent-darker-background-color table th,
.wp-block-table.has-surface-accent-darker-background-color table td,
.wp-block-table.has-surface-accent-darker-background-color table th *,
.wp-block-table.has-surface-accent-darker-background-color table td *,
.wp-block-table.has-surface-accent-darker-background-color table a,
figure.wp-block-table table.has-surface-accent-darkest-background-color,
figure.wp-block-table table.has-surface-accent-darkest-background-color *,
table.has-surface-accent-darkest-background-color,
table.has-surface-accent-darkest-background-color *,
figure.wp-block-table table.has-surface-accent-darkest-background-color th,
figure.wp-block-table table.has-surface-accent-darkest-background-color td,
figure.wp-block-table table.has-surface-accent-darkest-background-color a,
table.has-surface-accent-darkest-background-color th,
table.has-surface-accent-darkest-background-color td,
table.has-surface-accent-darkest-background-color a,
figure.wp-block-table table.has-primary-background-color,
figure.wp-block-table table.has-primary-background-color *,
table.has-primary-background-color,
table.has-primary-background-color *,
figure.wp-block-table table.has-primary-background-color th,
figure.wp-block-table table.has-primary-background-color td,
figure.wp-block-table table.has-primary-background-color a,
table.has-primary-background-color th,
table.has-primary-background-color td,
table.has-primary-background-color a,
figure.wp-block-table table.has-secondary-background-color,
figure.wp-block-table table.has-secondary-background-color *,
table.has-secondary-background-color,
table.has-secondary-background-color *,
figure.wp-block-table table.has-secondary-background-color th,
figure.wp-block-table table.has-secondary-background-color td,
figure.wp-block-table table.has-secondary-background-color a,
table.has-secondary-background-color th,
table.has-secondary-background-color td,
table.has-secondary-background-color a,
figure.wp-block-table table.has-galactic-background-background-color,
figure.wp-block-table table.has-galactic-background-background-color *,
table.has-galactic-background-background-color,
table.has-galactic-background-background-color *,
figure.wp-block-table table.has-galactic-background-background-color th,
figure.wp-block-table table.has-galactic-background-background-color td,
figure.wp-block-table table.has-galactic-background-background-color a,
table.has-galactic-background-background-color th,
table.has-galactic-background-background-color td,
table.has-galactic-background-background-color a {
  color: var(
    --wp--custom--semantic--color--text--inverse,
    var(--wp--custom--primitive--color--neutral--0, #ffffff)
  ) !important;
}

/* Bordures pour fonds sombres - bordures claires */
table.has-surface-brand-background-color th,
table.has-surface-brand-background-color td,
table.has-surface-inverse-background-color th,
table.has-surface-inverse-background-color td,
table.has-surface-accent-dark-background-color th,
table.has-surface-accent-dark-background-color td,
table.has-surface-accent-darker-background-color th,
table.has-surface-accent-darker-background-color td,
table.has-surface-accent-darkest-background-color th,
table.has-surface-accent-darkest-background-color td,
table.has-primary-background-color th,
table.has-primary-background-color td,
table.has-secondary-background-color th,
table.has-secondary-background-color td,
table.has-galactic-background-background-color th,
table.has-galactic-background-background-color td {
  border-color: var(
    --wp--custom--primitive--color--alpha--light--100,
    rgba(255, 255, 255, 0.1)
  ) !important;
}

/* Backgrounds clairs - texte sombre */
figure.wp-block-table table.has-surface-body-background-color *,
table.has-surface-body-background-color *,
figure.wp-block-table table.has-surface-primary-background-color *,
table.has-surface-primary-background-color *,
figure.wp-block-table table.has-surface-secondary-background-color *,
table.has-surface-secondary-background-color *,
figure.wp-block-table table.has-surface-tertiary-background-color *,
table.has-surface-tertiary-background-color *,
figure.wp-block-table table.has-surface-accent-lightest-background-color *,
table.has-surface-accent-lightest-background-color *,
figure.wp-block-table table.has-surface-accent-lighter-background-color *,
table.has-surface-accent-lighter-background-color *,
figure.wp-block-table table.has-surface-accent-light-background-color *,
table.has-surface-accent-light-background-color *,
figure.wp-block-table table.has-surface-background-color *,
table.has-surface-background-color *,
figure.wp-block-table table.has-accent-background-color *,
table.has-accent-background-color * {
  color: var(
    --wp--custom--semantic--color--text--primary,
    var(--wp--custom--primitive--color--neutral--900, #121212)
  ) !important;
}

/* Link styles in tables */
.wp-block-table a {
  font-weight: var(--wp--custom--primitive--font--weight--800, Heavy);
  text-decoration: none;
}

.wp-block-table a:hover {
  text-decoration: underline;
}

/* Striped table support */
/* Lignes impaires - fond blanc */
figure.wp-block-table.is-style-stripes tbody tr:nth-child(odd),
.wp-block-table.is-style-stripes tbody tr:nth-child(odd) {
  background-color: var(
    --wp--custom--semantic--color--background--surface--primary,
    var(--wp--custom--primitive--color--neutral--0, #ffffff)
  ) !important;
}

/* Lignes paires - fond gris clair tokenisé */
figure.wp-block-table.is-style-stripes tbody tr:nth-child(even),
.wp-block-table.is-style-stripes tbody tr:nth-child(even) {
  background-color: var(
    --wp--custom--semantic--color--background--surface--secondary,
    var(--wp--custom--primitive--color--neutral--100, #f4f5f6)
  ) !important;
}

/* Forcer le texte en noir sur les lignes rayées pour les rendre lisibles */
figure.wp-block-table.is-style-stripes tbody tr *,
.wp-block-table.is-style-stripes tbody tr *,
figure.wp-block-table.is-style-stripes tbody tr th,
figure.wp-block-table.is-style-stripes tbody tr td,
figure.wp-block-table.is-style-stripes tbody tr a,
.wp-block-table.is-style-stripes tbody tr th,
.wp-block-table.is-style-stripes tbody tr td,
.wp-block-table.is-style-stripes tbody tr a {
  color: var(
    --wp--custom--semantic--color--text--primary,
    var(--wp--custom--primitive--color--neutral--900, #121212)
  ) !important;
}
