/* =====================================================
   PREMIUM HEADER — Ma'rifat Allah
   Fichier principal — propre et complet
   ===================================================== */

:root {
  --header-height: 70px;
  --primary: #2D5F4F;
  --primary-light: #4A8B73;
  --accent: #C9A661;
  --bg: #F8FAF8;
  --surface: #FFFFFF;
  --text: #1F2937;
  --text-light: #6B7280;
  --border: rgba(45, 95, 79, 0.12);
}

[data-theme="dark"] {
  --bg: #0F1419;
  --surface: #1A202C;
  --text: #E5E7EB;
  --text-light: #9CA3AF;
  --border: rgba(255, 255, 255, 0.08);
}

/* ===== HEADER PRINCIPAL ===== */
.premium-header {
  position: sticky !important;
  top: 0 !important;
  left: 0;
  width: 100%;
  background: var(--surface, #FFFFFF) !important;
  border-bottom: 1px solid rgba(45, 95, 79, 0.1);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  z-index: 1000;
  transition: all 0.3s ease;
}

.premium-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

/* ===== LOGO / BRAND ===== */
.premium-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
}

.brand-logo-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: 'Amiri', serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
  line-height: 1.2;
}

.brand-tagline {
  font-size: 0.68rem;
  color: var(--text-light);
  margin: 0;
  white-space: nowrap;
}

/* ===== NAVIGATION DESKTOP ===== */
.premium-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  justify-content: center;
}

/* ── Bouton nav de base ── */
.nav-btn {
  position: relative;
  display: inline-flex !important;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.95rem;
  background: transparent;
  border: none;
  border-radius: 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text, #1F2937);
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
  text-decoration: none;
  white-space: nowrap;
  /* reset de tout conflit externe */
  opacity: 1 !important;
  visibility: visible !important;
  overflow: visible !important;
  animation: none !important;
  transform: none !important;
}

.nav-btn:hover {
  background: rgba(45, 95, 79, 0.07);
  color: var(--primary);
}

.nav-btn.active {
  background: rgba(45, 95, 79, 0.09);
  color: var(--primary);
  font-weight: 600;
}

/* ── Conteneur interne du bouton ── */
.nav-btn-content {
  display: flex !important;
  align-items: center !important;
  gap: 0.4rem !important;
  opacity: 1 !important;
  visibility: visible !important;
  animation: none !important;
  transform: none !important;
}

/* ── Icône emoji ── */
.nav-btn-icon {
  font-size: 1rem;
  display: inline !important;
  opacity: 1 !important;
  visibility: visible !important;
  animation: none !important;
  transform: none !important;
}

/* ── TEXTE du bouton nav — le cœur du problème ── */
.nav-btn-text {
  display: inline !important;
  visibility: visible !important;
  opacity: 1 !important;
  color: var(--text, #1F2937) !important;
  font-size: 0.9rem !important;
  font-weight: 500 !important;
  font-family: 'Outfit', sans-serif !important;
  /* annule toute animation qui partirait de opacity:0 */
  animation: none !important;
  transform: none !important;
  position: static !important;
  width: auto !important;
  height: auto !important;
  overflow: visible !important;
  clip: auto !important;
  clip-path: none !important;
}

.nav-btn:hover .nav-btn-text,
.nav-btn.active .nav-btn-text {
  color: var(--primary, #2D5F4F) !important;
}

/* ── Badge "CORAN" ── */
.nav-btn-badge {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  background: var(--accent, #C9A661) !important;
  color: white !important;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.12rem 0.38rem;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  animation: none !important;
  transform: none !important;
}

/* ── Flèche dropdown ── */
.nav-btn-arrow {
  display: inline-block !important;
  visibility: visible !important;
  opacity: 0.6 !important;
  margin-left: 0.15rem;
  transition: transform 0.3s ease;
  animation: none !important;
  flex-shrink: 0;
}

.nav-btn.has-panel.panel-open .nav-btn-arrow {
  transform: rotate(180deg);
}

/* Glow décoratif (optionnel) */
.nav-btn-glow {
  display: none;
}

/* ===== ACTIONS DROITE ===== */
.premium-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.action-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  color: var(--text);
  font-size: 1.1rem;
  transition: all 0.25s ease;
  position: relative;
}

.action-btn:hover {
  background: rgba(45, 95, 79, 0.08);
  color: var(--primary);
}

/* Toggle thème */
.sun-icon,
.moon-icon {
  transition: opacity 0.3s ease, transform 0.3s ease;
  position: absolute;
}

[data-theme="light"] .moon-icon,
[data-theme="dark"] .sun-icon {
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
}

[data-theme="light"] .sun-icon,
[data-theme="dark"] .moon-icon {
  opacity: 1;
  transform: scale(1);
}

/* Bouton connexion / utilisateur */
.premium-login-btn,
#header-user-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.15rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  position: relative;
}

.premium-login-btn:hover,
#header-user-btn:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(45, 95, 79, 0.22);
}

.login-btn-mobile-icon {
  display: none;
}

/* ===== BURGER MOBILE ===== */
.premium-burger {
  display: none;
  flex-direction: column;
  gap: 5px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.3s ease;
  flex-shrink: 0;
}

.premium-burger:hover {
  background: rgba(45, 95, 79, 0.08);
}

.burger-line {
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s ease;
  transform-origin: center;
}

.premium-burger.active .burger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.premium-burger.active .burger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.premium-burger.active .burger-line:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ===== PANELS DÉROULANTS ===== */
.premium-panel {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  background: transparent;
  pointer-events: none;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.35s;
}

.premium-panel.active {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

.panel-backdrop {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.premium-panel.active .panel-backdrop {
  opacity: 1;
  pointer-events: all;
}

.panel-content {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  background: var(--surface);
  border-radius: 0 0 20px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.14);
  transform: translateY(-8px);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.premium-panel.active .panel-content {
  transform: translateY(0);
}

/* ===== GRILLE PANEL ===== */
.panel-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.panel-section.full-width {
  grid-column: 1 / -1;
}

.panel-section-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  margin-bottom: 0.35rem;
}

.section-icon {
  font-size: 1rem;
}

/* ===== CARTES PANEL ===== */
.panel-cards {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.panel-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.9rem;
  padding: 0.9rem 1.1rem;
  background: var(--surface);
  border: 1.5px solid rgba(45, 95, 79, 0.08);
  border-radius: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.panel-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--primary);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.panel-card:hover {
  transform: translateX(4px);
  border-color: rgba(45, 95, 79, 0.22);
  box-shadow: 0 4px 14px rgba(45, 95, 79, 0.09);
}

.panel-card:hover::before {
  opacity: 1;
}

.card-icon-wrapper {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: rgba(45, 95, 79, 0.08);
  flex-shrink: 0;
}

.card-icon {
  font-size: 1.4rem;
}

.card-content {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.15rem 0;
}

.card-desc {
  font-size: 0.8rem;
  color: var(--text-light);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-arrow {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: rgba(45, 95, 79, 0.05);
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--text-light);
  transition: all 0.25s ease;
}

.panel-card:hover .card-arrow {
  background: var(--primary);
  color: white;
  transform: translateX(2px);
}

.panel-card.card-green .card-icon-wrapper   { background: rgba(45, 95, 79, 0.1); }
.panel-card.card-emerald .card-icon-wrapper { background: rgba(74, 139, 115, 0.1); }
.panel-card.card-gold .card-icon-wrapper    { background: rgba(201, 166, 97, 0.1); }
.panel-card.card-blue .card-icon-wrapper    { background: rgba(59, 130, 246, 0.1); }

/* ===== HIGHLIGHT ===== */
.panel-highlight {
  background: linear-gradient(135deg, #2D5F4F, #4A8B73);
  border-radius: 16px;
  padding: 1.65rem;
  color: white;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.highlight-stars {
  display: flex;
  gap: 0.25rem;
  justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 0.65rem;
}

.highlight-title {
  font-family: 'Amiri', serif;
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 0.4rem 0;
}

.highlight-text {
  font-size: 0.88rem;
  opacity: 0.88;
  margin-bottom: 1.1rem;
}

.highlight-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 1.4rem;
  background: white;
  color: var(--primary);
  border: none;
  border-radius: 9px;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.highlight-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

/* ===== OUTILS GRILLE ===== */
.tools-grid-premium {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.85rem;
}

.tool-card-premium {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  padding: 1.35rem 1rem;
  background: var(--surface);
  border: 1.5px solid rgba(45, 95, 79, 0.08);
  border-radius: 15px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.tool-card-premium:hover {
  transform: translateY(-5px);
  border-color: rgba(45, 95, 79, 0.2);
  box-shadow: 0 10px 28px rgba(45, 95, 79, 0.11);
}

.tool-icon-wrapper {
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: rgba(45, 95, 79, 0.08);
}

.tool-icon {
  font-size: 1.85rem;
}

.tool-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.tool-desc {
  font-size: 0.78rem;
  color: var(--text-light);
  margin: 0;
  line-height: 1.4;
}

.tool-card-premium.card-teal   .tool-icon-wrapper { background: rgba(20, 184, 166, 0.1); }
.tool-card-premium.card-cyan   .tool-icon-wrapper { background: rgba(6, 182, 212, 0.1); }
.tool-card-premium.card-indigo .tool-icon-wrapper { background: rgba(99, 102, 241, 0.1); }
.tool-card-premium.card-amber  .tool-icon-wrapper { background: rgba(245, 158, 11, 0.1); }
.tool-card-premium.card-green  .tool-icon-wrapper { background: rgba(45, 95, 79, 0.1); }
.tool-card-premium.card-gold   .tool-icon-wrapper { background: rgba(201, 166, 97, 0.1); }

/* ===== MENU MOBILE ===== */
.premium-mobile-menu {
  position: fixed;
  top: 0;
  left: -100%;
  width: 300px;
  max-width: 88vw;
  height: 100dvh;
  background: var(--surface);
  box-shadow: 6px 0 30px rgba(0, 0, 0, 0.14);
  z-index: 10001;
  transition: left 0.38s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.premium-mobile-menu.active {
  left: 0;
}

.mobile-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid rgba(45, 95, 79, 0.1);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.mobile-brand-name {
  font-family: 'Amiri', serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
}

.mobile-close-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.2s;
}

.mobile-close-btn:hover {
  background: rgba(45, 95, 79, 0.08);
}

.mobile-nav-premium {
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.mobile-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: transparent;
  border: none;
  border-radius: 11px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.22s ease;
  width: 100%;
  text-align: left;
}

.mobile-nav-item:hover,
.mobile-nav-item.expandable.active {
  background: rgba(45, 95, 79, 0.07);
  color: var(--primary);
}

.mobile-nav-item.highlight {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.mobile-nav-item.highlight:hover {
  background: var(--primary-light);
}

.mobile-nav-icon {
  font-size: 1.15rem;
  flex-shrink: 0;
}

.mobile-nav-text {
  flex: 1;
}

.mobile-nav-arrow {
  margin-left: auto;
  font-size: 0.7rem;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0.6;
  flex-shrink: 0;
}

.mobile-nav-item.expandable.active .mobile-nav-arrow {
  transform: rotate(180deg);
  opacity: 1;
}

.mobile-submenu {
  display: none;
  flex-direction: column;
  gap: 0.2rem;
  padding-left: 2.25rem;
  margin-top: 0.15rem;
  overflow: hidden;
}

.mobile-submenu.active {
  display: flex !important;
}


.mobile-submenu a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.mobile-submenu a:hover {
  background: rgba(45, 95, 79, 0.07);
  color: var(--primary);
  padding-left: 1rem;
}

.mobile-nav-divider {
  height: 1px;
  background: rgba(45, 95, 79, 0.1);
  margin: 0.4rem 0;
}

/* ===== NO SCROLL ===== */
body.no-scroll {
  overflow: hidden;
}

/* ===== MODE SOMBRE ===== */
[data-theme="dark"] .premium-header {
  border-bottom-color: rgba(255, 255, 255, 0.07);
}

[data-theme="dark"] .nav-btn {
  color: var(--text, #E5E7EB);
}

[data-theme="dark"] .nav-btn-text {
  color: var(--text, #E5E7EB) !important;
}

[data-theme="dark"] .nav-btn:hover .nav-btn-text,
[data-theme="dark"] .nav-btn.active .nav-btn-text {
  color: #6ee7b7 !important;
}

[data-theme="dark"] .panel-content,
[data-theme="dark"] .panel-card,
[data-theme="dark"] .tool-card-premium,
[data-theme="dark"] .premium-mobile-menu,
[data-theme="dark"] .mobile-menu-header {
  background: var(--surface);
  border-color: rgba(255, 255, 255, 0.07);
}

[data-theme="dark"] .card-title,
[data-theme="dark"] .tool-title {
  color: var(--text);
}

/* ===== FIX PANEL DÉCOUVERTE ===== */
#panelDecouverte .tools-grid-premium {
  grid-template-columns: repeat(5, 1fr) !important;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  #panelDecouverte .tools-grid-premium {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

@media (max-width: 1024px) {
  .panel-grid {
    grid-template-columns: 1fr;
  }

  .premium-nav .nav-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 768px) {
  .premium-nav {
    display: none;
  }

  .premium-burger {
    display: flex;
  }

  .premium-actions {
    gap: 0.3rem;
  }

  .premium-login-btn,
  #header-user-btn {
    padding: 0.5rem 0.9rem;
    font-size: 0.82rem;
  }

  .brand-name {
    font-size: 1.1rem;
  }

  .brand-tagline {
    display: none;
  }

  .panel-content {
    border-radius: 0 0 16px 16px;
    padding: 1rem;
    max-height: calc(100dvh - var(--header-height) - 1rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tools-grid-premium,
  #panelDecouverte .tools-grid-premium {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 480px) {
  .premium-container {
    padding: 0 0.85rem;
    gap: 0.75rem;
  }

  .brand-logo-wrapper {
    width: 38px;
    height: 38px;
  }

  .premium-login-btn span:not(.btn-icon),
  #header-user-btn #header-user-name {
    display: none;
  }

  .login-btn-mobile-icon {
    display: inline-block;
    font-size: 1.15rem;
  }

  .premium-login-btn,
  #header-user-btn {
    padding: 0.5rem 0.65rem;
    min-width: 38px;
    justify-content: center;
  }

  .header-logout-btn {
    display: none;
  }

  .tools-grid-premium,
  #panelDecouverte .tools-grid-premium {
    grid-template-columns: 1fr 1fr !important;
  }
}