/* =================================================================
   BRAZZA-MARKET — HEADER PROFESSIONNEL v2
   2 rangées desktop · repli propre tablette · mobile-first absolu
   ⚠️ Ce fichier doit être chargé EN DERNIER (après header-universel.css
   et auth.css) pour que ses règles gagnent les conflits.
================================================================= */

:root {
  --primary: #46955c;
  --primary-dark: #1a5c34;
  --primary-light: #73dd91;
  --accent: #ffd700;
  --hh-top: 68px;              /* hauteur rangée 1 (desktop) */
  --hh-nav: 46px;              /* hauteur rangée 2 (desktop) */
  --radius-pill: 50px;
  --shadow-header: 0 2px 16px rgba(0,0,0,.08);
}

/* Corps : compense le header fixe (2 rangées) */
body { padding-top: calc(var(--hh-top) + var(--hh-nav)); }

/* =================================================================
   COQUILLE DU HEADER
================================================================= */
.header-professionnel,
#monHeader {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: rgba(255,255,255,.98);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-header);
}
body.dark-mode .header-professionnel,
body.dark-mode #monHeader {
  background: rgba(15,20,25,.98);
  box-shadow: 0 2px 16px rgba(0,0,0,.45);
}

/* =================================================================
   RANGÉE 1 : LOGO | RECHERCHE | ACTIONS
================================================================= */
.header-top {
  max-width: 1440px; margin: 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px; height: var(--hh-top);
}

/* Logo */
.header-logo { flex: 0 0 auto; display: flex; align-items: center; }
.header-logo img { height: 44px; width: auto; display: block; }

/* Recherche centrée, flexible */
.header-search-wrap { flex: 1 1 auto; display: flex; justify-content: center; padding: 0 8px; min-width: 0; }
.header-search { width: 100%; max-width: 620px; position: relative; }
.header-search .search-icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: #8a94a0; font-size: 14px; pointer-events: none; transition: color .2s;
}
.header-search-input {
  width: 100%; height: 42px;
  padding: 0 18px 0 42px;
  border-radius: var(--radius-pill);
  border: 1.5px solid rgba(70,149,92,.25);
  background: #f2f5f4; font-size: 14px; font-family: inherit;
  color: #2d3436; transition: all .25s ease;
}
.header-search-input::placeholder { color: #98a2ad; }
.header-search-input:focus {
  outline: none; border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 4px rgba(70,149,92,.14);
}
.header-search-input:focus ~ .search-icon,
.header-search:focus-within .search-icon { color: var(--primary); }
body.dark-mode .header-search-input { background: #1a2230; border-color: #2d3748; color: #eaeaea; }
body.dark-mode .header-search-input::placeholder { color: #6b7684; }
body.dark-mode .header-search-input:focus { background: #0f1419; border-color: var(--primary-light); box-shadow: 0 0 0 4px rgba(115,221,145,.12); }
body.dark-mode .header-search .search-icon { color: #73dd91; }

/* Actions à droite */
.header-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; margin-left: auto; }

.toolbar-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: rgba(70,149,92,.10);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .25s ease; position: relative; flex-shrink: 0;
}
.toolbar-btn:hover { background: rgba(70,149,92,.2); transform: scale(1.08); }
.toolbar-btn i { font-size: 15px; color: var(--primary); transition: color .2s; }
body.dark-mode .toolbar-btn { background: rgba(115,221,145,.12); }
body.dark-mode .toolbar-btn:hover { background: rgba(115,221,145,.22); }
body.dark-mode .toolbar-btn i { color: var(--primary-light); }
/* Icône thème bien visible : lune verte (clair) / soleil doré (sombre) */
#themeToggle i { color: var(--primary); }
body.dark-mode #themeToggle i { color: var(--accent); }

.toolbar-divider { width: 1px; height: 22px; background: linear-gradient(180deg,transparent,rgba(115,221,145,.35),transparent); margin: 0 2px; }

/* Badge notifications */
.notif-badge {
  position: absolute; top: 0; right: 0;
  background: linear-gradient(135deg,#ff4757,#ff3838); color: #fff;
  font-size: 9px; font-weight: 700; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff; animation: pulse-badge 2s infinite;
}
body.dark-mode .notif-badge { border-color: #0f1419; }
@keyframes pulse-badge { 0%,100%{transform:scale(1);} 50%{transform:scale(1.12);} }

/* Chip utilisateur (avatar + nom + flèche) */
.user-menu-wrapper { position: relative; }
.toolbar-user {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 4px; border-radius: var(--radius-pill);
  cursor: pointer; transition: background .25s ease;
  background: rgba(70,149,92,.10);
}
.toolbar-user:hover { background: rgba(70,149,92,.2); }
body.dark-mode .toolbar-user { background: rgba(115,221,145,.12); }
body.dark-mode .toolbar-user:hover { background: rgba(115,221,145,.22); }
.toolbar-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg,#46955c,#73dd91);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 12px;
  border: 2px solid rgba(255,255,255,.35); flex-shrink: 0;
}
.toolbar-user-name {
  font-weight: 600; font-size: 13px; color: #2d3436;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
body.dark-mode .toolbar-user-name { color: #eaeaea; }
.toolbar-user-arrow { font-size: 9px; color: var(--primary); transition: transform .25s; }
body.dark-mode .toolbar-user-arrow { color: var(--primary-light); }
.toolbar-user:hover .toolbar-user-arrow { transform: rotate(180deg); }

/* Boutons Connexion / Inscription */
.btn-outline {
  padding: 8px 18px; border-radius: var(--radius-pill); font-weight: 600; font-size: 13px;
  text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
  border: 2px solid rgba(70,149,92,.35); background: rgba(70,149,92,.05); color: var(--primary);
  transition: all .25s ease; white-space: nowrap;
}
.btn-outline:hover { background: rgba(70,149,92,.15); border-color: var(--primary); transform: translateY(-1px); }
.btn-primary {
  padding: 9px 20px; border-radius: var(--radius-pill); font-weight: 700; font-size: 13px;
  text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg,#46955c,#73dd91); color: #fff;
  box-shadow: 0 5px 14px rgba(70,149,92,.3); border: none; white-space: nowrap; transition: all .25s ease;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 7px 18px rgba(70,149,92,.4); }
body.dark-mode .btn-outline { border-color: rgba(115,221,145,.35); background: rgba(115,221,145,.05); color: var(--primary-light); }

/* =================================================================
   RANGÉE 2 : NAVIGATION CENTRÉE
================================================================= */
.header-nav {
  max-width: 1440px; margin: 0 auto;
  display: flex; justify-content: center; align-items: center;
  gap: 4px; padding: 0 16px; height: var(--hh-nav);
  border-top: 1px solid rgba(70,149,92,.12);
}
body.dark-mode .header-nav { border-top-color: rgba(115,221,145,.12); }

.nav-link {
  padding: 8px 16px; border-radius: 10px; text-decoration: none;
  color: #333; font-weight: 500; font-size: 14px; white-space: nowrap;
  background: none; border: none; cursor: pointer; font-family: inherit;
  transition: all .25s ease;
}
body.dark-mode .nav-link { color: #eaeaea; }
.nav-link:hover { background: rgba(70,149,92,.12); color: var(--primary-dark); }
body.dark-mode .nav-link:hover { background: rgba(115,221,145,.14); color: var(--primary-light); }
.nav-link.active {
  background: linear-gradient(135deg,#46955c,#3d9c58); color: #fff !important;
  font-weight: 600; box-shadow: 0 4px 12px rgba(70,149,92,.3);
}

/* Dropdowns de navigation */
.nav-dropdown { position: relative; }
.nav-dropdown-trigger { display: inline-flex; align-items: center; gap: 6px; }
.nav-dropdown-trigger i { font-size: 10px; transition: transform .2s; }
.nav-dropdown.open .nav-dropdown-trigger i { transform: rotate(180deg); }
.nav-dropdown-menu {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 260px; max-height: 480px; overflow-y: auto;
  background: #fff; border-radius: 14px; box-shadow: 0 12px 32px rgba(0,0,0,.14);
  padding: 8px; opacity: 0; visibility: hidden; transform: translateY(-8px);
  transition: all .2s ease; z-index: 1000;
}
body.dark-mode .nav-dropdown-menu { background: #1a1f2e; box-shadow: 0 12px 32px rgba(0,0,0,.5); }
.nav-dropdown.open .nav-dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-item-main { font-weight: 600; background: rgba(70,149,92,.08); border-radius: 8px; }
body.dark-mode .dropdown-item-main { background: rgba(115,221,145,.1); }
.dropdown-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #999; padding: 6px 14px 4px; }

/* Dropdown utilisateur */
.user-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0;
  background: #fff; border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.16);
  min-width: 280px; opacity: 0; visibility: hidden; transform: translateY(-10px);
  transition: all .3s ease; z-index: 1002; overflow: hidden;
}
body.dark-mode .user-dropdown { background: #1a1a2e; }
.user-dropdown.show { opacity: 1; visibility: visible; transform: translateY(0); }
.dropdown-header { background: linear-gradient(135deg,#1a5c34,#46955c); padding: 22px; text-align: center; color: #fff; }
.avatar-large { width: 64px; height: 64px; border-radius: 50%; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 24px; margin: 0 auto 12px; }
.user-fullname { font-weight: 700; font-size: 16px; margin-bottom: 4px; color: #fff; }
.user-email { font-size: 13px; opacity: .95; color: #fff; }
.dropdown-menu { padding: 8px 0; }
.dropdown-item { display: flex; align-items: center; gap: 14px; padding: 12px 22px; text-decoration: none; color: #333; transition: all .25s ease; }
.dropdown-item:hover { background: rgba(70,149,92,.1); color: var(--primary); padding-left: 26px; }
.dropdown-item i { font-size: 16px; width: 22px; text-align: center; color: var(--primary); }
body.dark-mode .dropdown-item { color: #eaeaea; }
body.dark-mode .dropdown-item:hover { color: var(--primary-light); }
.dropdown-divider { height: 1px; background: rgba(0,0,0,.08); margin: 6px 0; }
body.dark-mode .dropdown-divider { background: rgba(255,255,255,.1); }

/* Hamburger */
.btn-mobile-menu {
  display: none; flex-direction: column; justify-content: center; align-items: center; gap: 5px;
  width: 42px; height: 42px; border: 1.5px solid rgba(115,221,145,.35); border-radius: 10px;
  background: rgba(115,221,145,.06); cursor: pointer; transition: all .25s ease; flex-shrink: 0;
}
.btn-mobile-menu:hover { background: rgba(115,221,145,.16); }
.btn-mobile-menu span { width: 20px; height: 2.5px; background: var(--primary-light); border-radius: 3px; transition: all .3s ease; }

/* =================================================================
   RESPONSIVE — TABLETTE (≤1280px) : nav → hamburger
================================================================= */
@media (max-width: 1280px) {
  body { padding-top: var(--hh-top); }
  .header-nav { display: none; }
  .btn-mobile-menu { display: flex; }
  .toolbar-user-name, .toolbar-user-arrow { display: none; }
  .toolbar-user { padding: 4px; }
}

/* =================================================================
   RESPONSIVE — MOBILE (≤768px) : recherche sur sa propre rangée
================================================================= */
@media (max-width: 768px) {
  :root { --hh-top: 112px; }   /* rangée 1 = logo+actions (56) + recherche (56) */
  .header-top { flex-wrap: wrap; height: auto; padding: 8px 12px; row-gap: 8px; }
  .header-logo { order: 1; }
  .header-logo img { height: 38px; }
  .header-actions { order: 2; margin-left: auto; }
  .header-search-wrap { order: 3; flex: 1 1 100%; padding: 0; }
  .header-search-input { height: 44px; font-size: 15px; }
  .toolbar-btn { width: 38px; height: 38px; }
}

/* =================================================================
   RESPONSIVE — PETIT MOBILE (≤480px) : ultra compact
================================================================= */
@media (max-width: 480px) {
  :root { --hh-top: 104px; }
  .header-top { padding: 8px 10px; }
  .header-logo img { height: 34px; }
  .toolbar-btn { width: 36px; height: 36px; }
  .toolbar-divider { display: none; }
  .btn-mobile-menu { width: 38px; height: 38px; }
  .header-search-input { height: 42px; }
  /* Connexion/Inscription → icônes rondes */
  .btn-outline, .btn-primary {
    padding: 0; font-size: 0; gap: 0; width: 36px; height: 36px;
    justify-content: center; border-radius: 50%; border-width: 0;
  }
  .btn-outline { background: rgba(70,149,92,.12); }
  .btn-outline::before { content: '\f007'; font-family: 'Font Awesome 6 Free'; font-weight: 900; font-size: 14px; color: var(--primary); }
  .btn-primary::before { content: '\f234'; font-family: 'Font Awesome 6 Free'; font-weight: 900; font-size: 14px; color: #fff; }
}

/* =================================================================
   MENU MOBILE OVERLAY
================================================================= */
.mobile-menu-overlay {
  position: fixed; inset: 0; background: rgba(26,26,46,.98); backdrop-filter: blur(20px);
  z-index: 2000; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 10px; opacity: 0; visibility: hidden; transition: all .4s cubic-bezier(.4,0,.2,1);
  overflow-y: auto; padding: 70px 0 40px;
}
.mobile-menu-overlay.active { opacity: 1; visibility: visible; }
.mobile-menu-overlay a { color: #fff; text-decoration: none; font-size: 17px; font-weight: 600; padding: 13px 24px; border-radius: 12px; transition: all .25s ease; width: 88%; display: flex; align-items: center; gap: 15px; }
.mobile-menu-overlay a:hover { background: rgba(115,221,145,.18); color: var(--primary-light); }
.mobile-menu-overlay .mobile-logout { color: #ff6b6b; }
.mobile-menu-overlay .close-btn { position: absolute; top: 16px; right: 16px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.1); border: none; color: #fff; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.mobile-menu-divider { width: 70%; height: 1px; background: rgba(255,255,255,.12); margin: 8px 0; }
.mobile-user-info { padding: 12px 20px; color: rgba(255,255,255,.85); font-size: .9rem; text-align: center; border-bottom: 1px solid rgba(255,255,255,.1); width: 88%; }
.mobile-user-info span { font-size: .75rem; color: var(--primary-light); }
.mobile-dropdown { width: 88%; }
.mobile-dropdown-trigger { width: 100%; background: rgba(255,255,255,.08); border: none; color: #fff; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; font-size: 17px; font-weight: 600; cursor: pointer; border-radius: 12px; font-family: inherit; }
.mobile-dropdown-trigger i.fa-chevron-down { transition: transform .2s; }
.mobile-dropdown.open .mobile-dropdown-trigger i.fa-chevron-down { transform: rotate(180deg); }
.mobile-dropdown-content { max-height: 0; overflow: hidden; transition: max-height .3s ease; padding-left: 10px; }
.mobile-dropdown.open .mobile-dropdown-content { max-height: 600px; overflow-y: auto; }
.mobile-sub-item { font-size: 15px !important; padding: 10px 16px !important; }
.mobile-sub-label { font-size: 11px; color: rgba(255,255,255,.6); text-transform: uppercase; letter-spacing: .5px; padding: 8px 16px 4px; font-weight: 700; }

/* =================================================================
   DROPDOWN NOTIFICATIONS
================================================================= */
.notifications-dropdown {
  position: fixed; top: calc(var(--hh-top) + 8px); right: 16px; width: 380px; max-width: calc(100vw - 24px);
  background: #fff; border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.16);
  z-index: 9998; opacity: 0; visibility: hidden; transform: translateY(-10px);
  transition: all .3s cubic-bezier(.4,0,.2,1); max-height: 70vh; overflow-y: auto;
}
body.dark-mode .notifications-dropdown { background: #16213e; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.notifications-dropdown.show { opacity: 1; visibility: visible; transform: translateY(0); }
.notifications-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; background: linear-gradient(135deg,#46955c,#73dd91); color: #fff; border-radius: 16px 16px 0 0; }
.notifications-header h3 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.notif-close-btn { background: rgba(255,255,255,.2); border: none; color: #fff; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.notif-header-actions { display: flex; gap: 8px; align-items: center; }
.notif-action-btn { background: rgba(255,255,255,.2); border: none; color: #fff; padding: 6px 12px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.notif-action-btn.danger:hover { background: rgba(231,76,60,.85); }
.notifications-count { padding: 12px 20px; background: rgba(70,149,92,.05); display: flex; justify-content: space-between; align-items: center; font-size: .9rem; color: var(--primary); font-weight: 600; }
.mark-all-read { background: none; border: none; color: var(--primary); cursor: pointer; font-size: .85rem; font-weight: 600; padding: 5px 10px; border-radius: 6px; }
.notifications-list { max-height: 50vh; overflow-y: auto; }
.notification-item { padding: 16px 20px; display: flex; gap: 14px; cursor: pointer; transition: all .25s ease; border-bottom: 1px solid rgba(0,0,0,.05); position: relative; align-items: flex-start; }
.notification-item:hover { background: rgba(70,149,92,.05); }
.notification-unread { background: rgba(70,149,92,.08); }
.notif-icon { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg,#46955c,#73dd91); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-weight: 600; color: #2d3436; margin-bottom: 4px; font-size: .95rem; }
body.dark-mode .notif-title { color: #eaeaea; }
.notif-message { color: #636e72; font-size: .85rem; line-height: 1.4; margin-bottom: 4px; }
body.dark-mode .notif-message { color: #a0a0a0; }
.notif-time { color: #b2bec3; font-size: .75rem; }
.notif-action-link { margin-top: 6px; font-size: .8rem; color: var(--primary); font-weight: 600; }
.notif-actions { display: flex; gap: 6px; opacity: 0; transition: opacity .25s; flex-shrink: 0; }
.notification-item:hover .notif-actions { opacity: 1; }
.notif-action-icon { background: rgba(70,149,92,.1); border: none; color: var(--primary); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.notif-action-icon.danger { background: rgba(231,76,60,.1); color: #e74c3c; }
.notif-dot { width: 10px; height: 10px; background: #e74c3c; border-radius: 50%; position: absolute; top: 18px; right: 18px; animation: pulse-badge 2s infinite; }
.notifications-empty { padding: 50px 20px; text-align: center; color: #b2bec3; }
.notifications-empty i { font-size: 3.5rem; margin-bottom: 16px; opacity: .5; }
@media (max-width: 480px) {
  .notifications-dropdown { right: 12px; left: 12px; width: auto; top: calc(var(--hh-top) + 6px); }
  .notif-actions { opacity: 1; }
}

/* Animations toast */
@keyframes slideInRight { from { transform: translateX(400px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOutRight { from { transform: translateX(0); opacity: 1; } to { transform: translateX(400px); opacity: 0; } }
@keyframes slideUp { from { transform: translate(-50%,100px); opacity: 0; } to { transform: translate(-50%,0); opacity: 1; } }

/* =====================================================
   PATCH FINITION HEADER
===================================================== */
/* Menus TOUJOURS au-dessus du bouton flottant */
.nav-dropdown-menu        { z-index: 1100; }
.user-dropdown            { z-index: 1200; }
.notifications-dropdown   { z-index: 1200; }
button[onclick*="ouvrirAssistantIA"],
.container-bouton-comment-marche { z-index: 900 !important; }

/* Scrollbar fine et discrète dans les menus */
.nav-dropdown-menu::-webkit-scrollbar { width: 5px; }
.nav-dropdown-menu::-webkit-scrollbar-track { background: transparent; }
.nav-dropdown-menu::-webkit-scrollbar-thumb { background: rgba(115,221,145,.35); border-radius: 3px; }

/* Cloche visible en mode sombre */
body.dark-mode button[onclick*="afficherNotifications"] i { color: #73dd91; }

/* Nom utilisateur : coupure propre */
.toolbar-user-name { max-width: 130px; }

/* 📱 Mobile : resserre l'espace entre le header et le hero */
@media (max-width: 768px) {
  .hero { padding-top: 28px !important; }
}