/* =========================================================
   ELIOZ CONNECT — ANNUAIRE AGENCES
   Design system partagé — light & dark mode
   Identité de marque : Elioz Connect (bleu #0047EE)
   Version 2.0 | Les Champions de la Créativité
   
   USAGE :
   - Couleur d'accent banque : surcharger --bank-accent-* sur la page
   - Thème clair/sombre : piloté par data-theme="light|dark" sur
     l'élément racine, avec fallback automatique sur les préférences
     système (prefers-color-scheme)
   ========================================================= */

/* ---------------------------------------------------------
   TOKENS — MODE CLAIR (par défaut)
   --------------------------------------------------------- */
:root,
[data-theme="light"] {
  /* Surfaces */
  --bg:             #f6f7fb;
  --surface:        #ffffff;
  --surface-alt:    #eef0f7;
  --surface-raised: #ffffff;

  /* Bordures */
  --border:         rgba(15, 23, 42, 0.08);
  --border-mid:     rgba(15, 23, 42, 0.14);

  /* Texte */
  --text:           #11142b;
  --text-muted:     #5b6072;
  --text-dim:       #9499ab;

  /* Identité Elioz Connect (fixe, ne change pas avec le thème banque) */
  --elioz-blue:        #0047ee;
  --elioz-blue-hover:  #0039bf;
  --elioz-blue-light:  rgba(0, 71, 238, 0.08);
  --elioz-blue-border: rgba(0, 71, 238, 0.25);

  /* Ombres */
  --shadow-card:   0 2px 12px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-accent: 0 0 0 1px var(--bank-accent-border), 0 6px 20px var(--bank-accent-glow);

  color-scheme: light;
}

/* ---------------------------------------------------------
   TOKENS — MODE SOMBRE
   --------------------------------------------------------- */
[data-theme="dark"] {
  --bg:             #0c0e15;
  --surface:        #14171f;
  --surface-alt:    #1b1f2b;
  --surface-raised: #1b1f2b;

  --border:         rgba(255, 255, 255, 0.08);
  --border-mid:     rgba(255, 255, 255, 0.14);

  --text:           #eceef5;
  --text-muted:     #9499ab;
  --text-dim:       #5e6376;

  --elioz-blue:        #2e6bff;
  --elioz-blue-hover:  #5685ff;
  --elioz-blue-light:  rgba(46, 107, 255, 0.14);
  --elioz-blue-border: rgba(46, 107, 255, 0.32);

  --shadow-card:   0 4px 20px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(0, 0, 0, 0.3);
  --shadow-accent: 0 0 0 1px var(--bank-accent-border), 0 6px 24px var(--bank-accent-glow);

  color-scheme: dark;
}

/* Respect des préférences système quand aucun data-theme explicite n'est posé */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg:             #0c0e15;
    --surface:        #14171f;
    --surface-alt:    #1b1f2b;
    --surface-raised: #1b1f2b;
    --border:         rgba(255, 255, 255, 0.08);
    --border-mid:     rgba(255, 255, 255, 0.14);
    --text:           #eceef5;
    --text-muted:     #9499ab;
    --text-dim:       #5e6376;
    --elioz-blue:        #2e6bff;
    --elioz-blue-hover:  #5685ff;
    --elioz-blue-light:  rgba(46, 107, 255, 0.14);
    --elioz-blue-border: rgba(46, 107, 255, 0.32);
    --shadow-card:   0 4px 20px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------
   COULEUR DE BANQUE — valeur par défaut, à surcharger par page
   (CA Atlantique Vendée = vert, exemple ci-dessous)
   --------------------------------------------------------- */
:root {
  --bank-accent:        #05674e;
  --bank-accent-hover:  #047a5c;
  --bank-accent-light:  rgba(5, 103, 78, 0.10);
  --bank-accent-border: rgba(5, 103, 78, 0.30);
  --bank-accent-glow:   rgba(5, 103, 78, 0.20);
}

[data-theme="dark"] {
  --bank-accent-light:  rgba(5, 103, 78, 0.16);
  --bank-accent-border: rgba(5, 103, 78, 0.38);
  --bank-accent-glow:   rgba(5, 103, 78, 0.28);
}

/* Typographie & rayons & transitions communs aux deux thèmes */
:root {
  --font-ui:   'Inter', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------------------------------------------------------
   RESET & BASE
   --------------------------------------------------------- */
.elioz-directory-page *,
.elioz-directory-page *::before,
.elioz-directory-page *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.elioz-directory-page {
  font-family: var(--font-ui);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  transition: background-color var(--transition), color var(--transition);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------
   LAYOUT WRAPPER
   --------------------------------------------------------- */
.dir-wrapper {
  max-width: 860px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

/* ---------------------------------------------------------
   EN-TÊTE : LOGO + BADGE BANQUE + TOGGLE THÈME
   --------------------------------------------------------- */
.dir-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 40px;
}

.dir-header__logo img {
  height: 32px;
  width: auto;
  display: block;
}

/* En mode sombre, le logo Elioz (qui est en bleu/noir par défaut)
   passe en variante blanche pour rester lisible.
   Prévoir un fichier elioz-logo-dark.svg en blanc. */
[data-theme="dark"] .dir-header__logo img.is-themed {
  content: var(--logo-dark-src, none);
  filter: brightness(0) invert(1);
}

.dir-header__divider {
  width: 1px;
  height: 24px;
  background: var(--border-mid);
  flex-shrink: 0;
}

.dir-header__badge {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bank-accent);
  background: var(--bank-accent-light);
  border: 1px solid var(--bank-accent-border);
  padding: 4px 10px;
  border-radius: 100px;
}

/* Tag identité Elioz Connect — toujours bleu marque, jamais surchargé */
.dir-header__elioz-tag {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--elioz-blue);
  background: var(--elioz-blue-light);
  border: 1px solid var(--elioz-blue-border);
  padding: 4px 10px;
  border-radius: 100px;
}

/* Bouton bascule clair / sombre */
.dir-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-mid);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.dir-theme-toggle:hover {
  color: var(--text);
  border-color: var(--elioz-blue-border);
}

.dir-theme-toggle:focus-visible {
  outline: 2px solid var(--elioz-blue);
  outline-offset: 2px;
}

.dir-theme-toggle svg { display: block; }
.dir-theme-toggle .icon-sun  { display: none; }
.dir-theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .dir-theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .dir-theme-toggle .icon-moon { display: none; }

/* ---------------------------------------------------------
   BLOC D'INTRODUCTION ACCESSIBILITÉ
   --------------------------------------------------------- */
.dir-intro {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.dir-intro::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--bank-accent), var(--elioz-blue));
}

.dir-intro__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--bank-accent);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dir-intro__title svg { flex-shrink: 0; }

.dir-intro__text {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

.dir-intro__modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.dir-intro__mode {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 100px;
  border: 1px solid var(--border-mid);
  color: var(--text);
  background: var(--surface-alt);
  letter-spacing: 0.03em;
}

.dir-intro__link {
  display: inline-block;
  margin-top: 12px;
  font-size: 13px;
  color: var(--elioz-blue);
  text-decoration: none;
  transition: opacity var(--transition);
}

.dir-intro__link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.dir-intro__link:focus-visible {
  outline: 2px solid var(--elioz-blue);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------------------------------------------------------
   BARRE DE RECHERCHE
   --------------------------------------------------------- */
.dir-search {
  position: relative;
  margin-bottom: 16px;
}

.dir-search__input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 12px 44px 12px 16px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.dir-search__input::placeholder { color: var(--text-dim); }

.dir-search__input:focus {
  border-color: var(--elioz-blue);
  box-shadow: 0 0 0 3px var(--elioz-blue-light);
}

.dir-search__icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

/* ---------------------------------------------------------
   COMPTEUR DE RÉSULTATS
   --------------------------------------------------------- */
.dir-count {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
  height: 18px;
}

.dir-count strong { color: var(--text-muted); }

/* ---------------------------------------------------------
   TABLEAU
   --------------------------------------------------------- */
.dir-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.dir-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.dir-table thead {
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border-mid);
}

.dir-table thead th {
  padding: 14px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}

.dir-table thead th:hover { color: var(--text-muted); }

.dir-table thead th .sort-icon::after { content: ' ↕'; opacity: 0.4; font-size: 10px; }
.dir-table thead th.sort-asc .sort-icon::after  { content: ' ↑'; opacity: 1; }
.dir-table thead th.sort-desc .sort-icon::after { content: ' ↓'; opacity: 1; }
.dir-table thead th.sort-asc,
.dir-table thead th.sort-desc { color: var(--elioz-blue); }

.dir-table thead th:last-child {
  width: 90px;
  text-align: center;
}

.dir-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.dir-table tbody tr:last-child { border-bottom: none; }
.dir-table tbody tr:hover { background: var(--surface-alt); }
.dir-table tbody tr.dir-hidden { display: none; }

.dir-table tbody td {
  padding: 13px 16px;
  color: var(--text);
  vertical-align: middle;
}

.dir-table tbody td:nth-child(2) {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

/* Bouton Appel — utilise la couleur banque, avec un fallback bleu Elioz
   si aucune couleur banque n'est définie sur la page */
.dir-call-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bank-accent, var(--elioz-blue));
  color: #fff;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.dir-call-btn:hover {
  background: var(--bank-accent-hover, var(--elioz-blue-hover));
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--bank-accent-glow, var(--elioz-blue-light));
}

.dir-call-btn:active { transform: translateY(0); }

.dir-call-btn:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.dir-call-btn svg { flex-shrink: 0; }

.dir-table td.dir-td-action { text-align: center; }

/* ---------------------------------------------------------
   ÉTAT VIDE (aucun résultat)
   --------------------------------------------------------- */
.dir-empty {
  display: none;
  text-align: center;
  padding: 48px 24px;
  color: var(--text-dim);
  font-size: 14px;
}

.dir-empty svg { display: block; margin: 0 auto 12px; opacity: 0.3; }
.dir-empty.visible { display: block; }

/* ---------------------------------------------------------
   PIED DE PAGE — mention identité Elioz Connect
   --------------------------------------------------------- */
.dir-footer {
  margin-top: 32px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

.dir-footer a {
  color: var(--elioz-blue);
  text-decoration: none;
}

.dir-footer a:hover { text-decoration: underline; }

/* ---------------------------------------------------------
   RESPONSIVE — Mobile
   --------------------------------------------------------- */
@media (max-width: 600px) {
  .dir-wrapper { padding: 28px 16px 60px; }
  .dir-header { margin-bottom: 28px; flex-wrap: wrap; }
  .dir-header__elioz-tag { margin-left: 0; order: 3; width: 100%; justify-content: center; }
  .dir-intro { padding: 18px 20px; }
  .dir-table { font-size: 13px; }
  .dir-table thead th,
  .dir-table tbody td { padding: 12px 12px; }
}

@media (max-width: 420px) {
  .dir-table thead th:nth-child(2),
  .dir-table tbody td:nth-child(2) { display: none; }
}

/* ---------------------------------------------------------
   ACCESSIBILITÉ — focus visible global, motion réduit
   --------------------------------------------------------- */
.elioz-directory-page a:focus-visible,
.elioz-directory-page button:focus-visible,
.elioz-directory-page input:focus-visible {
  outline: 2px solid var(--elioz-blue);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .elioz-directory-page,
  .dir-call-btn,
  .dir-search__input,
  .dir-table tbody tr,
  .dir-theme-toggle {
    transition: none;
  }
}