/* ============================================================
   ZoodoMedia — Sidebar thème + Sélecteur de langue
   Version améliorée
   ============================================================ */

/* ══════════════════════════════════════════════════════════
   1. CORRECTION SIDEBAR — MODE CLAIR
   ══════════════════════════════════════════════════════════ */

/* Override forcé : la sidebar DOIT suivre le thème */
:root {
  --zm-sidebar-bg:   #ffffff;
  --zm-bg-sidebar:   #ffffff;
  --bg-sidebar:      #ffffff;
}

[data-theme="dark"] {
  --zm-sidebar-bg:   #0d2800;
  --zm-bg-sidebar:   #0d2800;
  --bg-sidebar:      #0d2800;
}

/* Sidebar principale */
.zm-sidebar {
  background: var(--zm-sidebar-bg) !important;
  border-right: 1px solid var(--zm-border) !important;
  transition: background .25s ease, border-color .25s ease,
              width .25s ease, transform .25s ease !important;
}

/* Scrollbar sidebar adaptée au thème */
.zm-sidebar::-webkit-scrollbar { width: 4px; }
.zm-sidebar::-webkit-scrollbar-track { background: transparent; }
.zm-sidebar::-webkit-scrollbar-thumb {
  background: var(--zm-border-dk);
  border-radius: 3px;
}

/* Nav links — couleurs adaptées aux deux thèmes */
.zm-nav-link {
  color: var(--zm-text-2) !important;
  position: relative;
  overflow: hidden;
}
.zm-nav-link::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: var(--zm-green);
  border-radius: 0 3px 3px 0;
  transition: height .2s ease;
}
.zm-nav-link:hover {
  background: var(--zm-hover) !important;
  color: var(--zm-text) !important;
}
.zm-nav-link:hover::before { height: 60%; }
.zm-nav-link.zm-active {
  background: var(--zm-active-bg) !important;
  color: var(--zm-active-txt) !important;
  font-weight: 600;
}
.zm-nav-link.zm-active::before { height: 70%; }

/* Divider sidebar */
.zm-nav-divider {
  background: var(--zm-border) !important;
}

/* Section title */
.zm-section-title {
  color: var(--zm-muted) !important;
}

/* Sidebar footer */
.zm-sidebar-footer {
  border-top: 1px solid var(--zm-border) !important;
  background: transparent !important;
}

/* Icône sociale */
.zm-social-ico {
  border-color: var(--zm-border) !important;
  color: var(--zm-muted) !important;
  background: var(--zm-surface) !important;
  transition: all .18s ease !important;
}
.zm-social-ico:hover {
  border-color: var(--zm-green) !important;
  color: var(--zm-green) !important;
  background: var(--zm-active-bg) !important;
  transform: translateY(-2px);
}

/* Copyright */
.zm-sidebar-copy {
  color: var(--zm-light) !important;
  font-size: .7rem;
  margin-top: 2px;
}

/* ══════════════════════════════════════════════════════════
   2. HEADER — Améliorations thème
   ══════════════════════════════════════════════════════════ */

.zm-header {
  background: var(--zm-header-bg) !important;
  border-bottom: 1px solid var(--zm-border) !important;
  box-shadow: var(--zm-shadow) !important;
}

/* Hamburger */
.zm-hamburger span {
  background: var(--zm-text) !important;
}
.zm-hamburger:hover { background: var(--zm-hover) !important; }

/* Barre de recherche */
.zm-search {
  background: var(--zm-search-bg) !important;
  border-color: var(--zm-border-dk) !important;
  transition: border-color .2s, box-shadow .2s, background .2s !important;
}
.zm-search:focus-within {
  border-color: var(--zm-green) !important;
  box-shadow: 0 0 0 3px rgba(40,145,0,.12) !important;
  background: var(--zm-surface) !important;
}
.zm-search input {
  color: var(--zm-text) !important;
  background: transparent !important;
}

/* Bouton thème — animation rotation */
#zm-theme-btn {
  transition: transform .3s ease, background .15s !important;
}
#zm-theme-btn:hover {
  transform: rotate(20deg) scale(1.1) !important;
  background: var(--zm-hover) !important;
}
[data-theme="dark"] #zm-theme-btn:hover {
  transform: rotate(-20deg) scale(1.1) !important;
}

/* ══════════════════════════════════════════════════════════
   3. SÉLECTEUR DE LANGUE — Design Premium
   ══════════════════════════════════════════════════════════ */

.zm-lang-wrap {
  position: relative;
  margin-bottom: 10px;
}

/* Bouton principal */
.zm-lang-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: var(--zm-surface);
  border: 1.5px solid var(--zm-border-dk);
  border-radius: 10px;
  cursor: pointer;
  font-size: .83rem;
  font-weight: 600;
  color: var(--zm-text);
  font-family: var(--zm-font);
  transition: all .18s ease;
  position: relative;
  overflow: hidden;
}
.zm-lang-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--zm-green);
  opacity: 0;
  transition: opacity .18s;
}
.zm-lang-btn:hover {
  border-color: var(--zm-green);
  color: var(--zm-green);
  box-shadow: 0 0 0 3px rgba(40,145,0,.1);
}
.zm-lang-btn:hover .zm-lang-globe-icon,
.zm-lang-btn:hover .zm-lang-chevron { color: var(--zm-green); }

.zm-lang-globe-icon {
  color: var(--zm-green);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.zm-lang-flag {
  font-size: 1rem;
  flex-shrink: 0;
  line-height: 1;
}
#zm-lang-current {
  flex: 1;
  text-align: left;
  font-size: .83rem;
  font-weight: 600;
}
.zm-lang-chevron {
  color: var(--zm-muted);
  flex-shrink: 0;
  transition: transform .22s ease, color .18s;
  display: flex;
  align-items: center;
}
.zm-lang-btn[aria-expanded="true"] .zm-lang-chevron {
  transform: rotate(180deg);
}

/* Dropdown */
.zm-lang-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--zm-surface);
  border: 1.5px solid var(--zm-border);
  border-radius: 12px;
  box-shadow: 0 -8px 32px rgba(0,0,0,.12), 0 0 0 1px rgba(40,145,0,.06);
  max-height: 300px;
  overflow-y: auto;
  z-index: 600;
  display: none;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: var(--zm-border-dk) transparent;
  animation: zmLangSlide .18s ease;
  border-top: 3px solid var(--zm-green);
}
[data-theme="dark"] .zm-lang-dropdown {
  box-shadow: 0 -8px 32px rgba(0,0,0,.4), 0 0 0 1px rgba(40,145,0,.1);
}
.zm-lang-dropdown.open { display: flex; }
.zm-lang-dropdown::-webkit-scrollbar { width: 4px; }
.zm-lang-dropdown::-webkit-scrollbar-thumb {
  background: var(--zm-border-dk);
  border-radius: 2px;
}

@keyframes zmLangSlide {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* Groupe titre */
.zm-lang-group-title {
  font-size: .67rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--zm-muted);
  padding: 9px 12px 5px;
  background: var(--zm-hover);
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--zm-border);
}

/* Item langue */
.zm-lang-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--zm-border);
  cursor: pointer;
  font-size: .84rem;
  color: var(--zm-text);
  font-family: var(--zm-font);
  text-align: left;
  transition: background .12s, color .12s;
  position: relative;
}
.zm-lang-item:last-child { border-bottom: none; }
.zm-lang-item:hover {
  background: var(--zm-hover);
  color: var(--zm-text);
}
.zm-lang-item-flag {
  font-size: 1.05rem;
  line-height: 1;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}
.zm-lang-item-name {
  flex: 1;
  font-weight: 500;
}
.zm-lang-item-code {
  font-size: .68rem;
  font-weight: 700;
  color: var(--zm-muted);
  background: var(--zm-hover);
  padding: 1px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}
.zm-lang-item.zm-lang-active {
  color: var(--zm-green);
  background: var(--zm-active-bg);
}
.zm-lang-item.zm-lang-active .zm-lang-item-name {
  font-weight: 700;
}
.zm-lang-item.zm-lang-active::after {
  content: '✓';
  position: absolute;
  right: 12px;
  font-size: .9rem;
  font-weight: 800;
  color: var(--zm-green);
}
.zm-lang-item.zm-lang-active .zm-lang-item-code {
  background: rgba(40,145,0,.12);
  color: var(--zm-green);
}

/* Search bar dans le dropdown */
.zm-lang-search-wrap {
  padding: 8px 10px;
  position: sticky;
  top: 0;
  background: var(--zm-surface);
  z-index: 3;
  border-bottom: 1px solid var(--zm-border);
}
.zm-lang-search {
  width: 100%;
  padding: 6px 10px 6px 30px;
  border: 1.5px solid var(--zm-border-dk);
  border-radius: 8px;
  background: var(--zm-search-bg);
  color: var(--zm-text);
  font-size: .82rem;
  font-family: var(--zm-font);
  outline: none;
  transition: border-color .15s;
}
.zm-lang-search:focus { border-color: var(--zm-green); }
.zm-lang-search::placeholder { color: var(--zm-muted); }
.zm-lang-search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--zm-muted);
  pointer-events: none;
  font-size: .8rem;
}
.zm-lang-search-wrap { position: relative; }

/* Toast langue amélioré */
#zm-lang-toast {
  position: fixed;
  bottom: 80px;
  left: 280px; /* À côté de la sidebar */
  transform: translateX(0) translateY(10px);
  background: linear-gradient(135deg, var(--zm-green) 0%, var(--zm-green-dk) 100%);
  color: #fff;
  padding: 10px 20px 10px 14px;
  border-radius: 12px;
  font-size: .84rem;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 18px rgba(40,145,0,.35);
  display: flex;
  align-items: center;
  gap: 8px;
}
#zm-lang-toast.show {
  opacity: 1;
  transform: translateX(0) translateY(0);
}
@media (max-width: 900px) {
  #zm-lang-toast {
    left: 50%;
    transform: translateX(-50%) translateY(10px);
  }
  #zm-lang-toast.show {
    transform: translateX(-50%) translateY(0);
  }
}

/* ══════════════════════════════════════════════════════════
   4. BOUTON THÈME — Améliorations visuelles
   ══════════════════════════════════════════════════════════ */

/* Indicateur visuel du mode actif dans le header */
.zm-theme-btn {
  position: relative;
}
.zm-theme-btn::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--zm-green);
  opacity: 0;
  transition: opacity .2s;
}
.zm-theme-btn:hover::after { opacity: 1; }

/* ══════════════════════════════════════════════════════════
   5. AMÉLIORATIONS GÉNÉRALES UI
   ══════════════════════════════════════════════════════════ */

/* Smooth transition globale pour le changement de thème */
*, *::before, *::after {
  transition-property: background-color, border-color, color, box-shadow;
  transition-duration: .2s;
  transition-timing-function: ease;
}
/* Ne pas transitionner les propriétés de layout */
.zm-sidebar, .zm-main, .zm-header, .zm-hamburger span {
  transition: background .2s ease, border-color .2s ease,
              width .25s ease, transform .25s ease,
              box-shadow .2s ease !important;
}

/* Dropdown user — amélioré */
.zm-dropdown {
  border-top: 3px solid var(--zm-green) !important;
}

/* Active nav link — bordure gauche verte visible */
.zm-nav-link.zm-active {
  border-left: 3px solid var(--zm-green);
  padding-left: 11px !important;
}

/* Hover sur icônes nav */
.zm-nav-icon {
  transition: transform .2s ease, color .15s !important;
}
.zm-nav-link:hover .zm-nav-icon {
  transform: scale(1.12);
}
.zm-nav-link.zm-active .zm-nav-icon {
  color: var(--zm-green);
}

/* Cat toggle */
.zm-cat-toggle {
  color: var(--zm-muted) !important;
  transition: transform .22s ease, color .15s !important;
}
.zm-cat-toggle:hover { color: var(--zm-green) !important; }

/* Live badge pulsing */
.zm-live-badge {
  box-shadow: 0 0 0 0 rgba(239,68,68,.4);
  animation: livepulse 1.2s ease infinite, liveGlow 2s ease infinite !important;
}
@keyframes liveGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4); }
  50%       { box-shadow: 0 0 0 4px rgba(239,68,68,.0); }
}

/* Focus visible amélioration accessibilité */
.zm-nav-link:focus-visible,
.zm-lang-btn:focus-visible,
.zm-lang-item:focus-visible {
  outline: 2px solid var(--zm-green);
  outline-offset: 2px;
}

/* ── Masquer les items filtrés dans la recherche langue ── */
.zm-lang-item[hidden] { display: none !important; }
.zm-lang-group-title.zm-hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════
   BOUTON LANGUE — HEADER (style compact)
══════════════════════════════════════════════════════════ */

.zm-lang-popup-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--zm-hover);
  border: 1.5px solid var(--zm-border-dk);
  border-radius: 10px;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 700;
  color: var(--zm-text);
  font-family: var(--zm-font);
  transition: all .18s ease;
  white-space: nowrap;
  height: 36px;
}
.zm-lang-popup-btn:hover {
  border-color: var(--zm-green);
  color: var(--zm-green);
  background: var(--zm-active-bg);
}
#zm-lang-hflag { font-size: 1rem; line-height: 1; }
#zm-lang-hlabel { font-size: .78rem; font-weight: 700; letter-spacing: .02em; }

/* ── Dropdown header ── */
.zm-lang-popup-dd {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--zm-surface);
  border: 1.5px solid var(--zm-border);
  border-top: 3px solid var(--zm-green);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.15);
  max-height: 380px;
  overflow-y: auto;
  z-index: 800;
  display: none;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: var(--zm-border-dk) transparent;
  animation: zmLdSlide .18s ease;
}
[data-theme="dark"] .zm-lang-popup-dd {
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.zm-lang-popup-dd.open { display: flex; }

@keyframes zmLdSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}

/* Groupe */
.zm-ld-group { display: flex; flex-direction: column; }
.zm-ld-group-title {
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--zm-muted);
  padding: 8px 12px 4px;
  background: var(--zm-hover);
  border-bottom: 1px solid var(--zm-border);
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Item */
.zm-ld-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--zm-border);
  cursor: pointer;
  font-size: .84rem;
  color: var(--zm-text);
  font-family: var(--zm-font);
  text-align: left;
  transition: background .12s;
  position: relative;
}
.zm-ld-item:last-child { border-bottom: none; }
.zm-ld-item:hover { background: var(--zm-hover); }
.zm-ld-flag  { font-size: 1rem; width: 22px; text-align: center; flex-shrink: 0; }
.zm-ld-name  { flex: 1; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zm-ld-code  {
  font-size: .65rem; font-weight: 800;
  color: var(--zm-muted); background: var(--zm-hover);
  padding: 1px 5px; border-radius: 4px; flex-shrink: 0;
}
.zm-ld-check {
  position: absolute;
  right: 10px;
  color: var(--zm-green);
  font-weight: 900;
  font-size: .88rem;
}
.zm-ld-item.zm-ld-active {
  background: var(--zm-active-bg);
  color: var(--zm-green);
}
.zm-ld-item.zm-ld-active .zm-ld-name { font-weight: 700; }
.zm-ld-item.zm-ld-active .zm-ld-code {
  background: rgba(40,145,0,.12);
  color: var(--zm-green);
}

/* Responsive : masquer le label sur petits écrans */
@media (max-width: 480px) {
  #zm-lang-hlabel { display: none; }
  .zm-lang-popup-btn { padding: 6px 8px; gap: 4px; }
  .zm-lang-popup-dd { right: -40px; width: 220px; }
}
