/* Nova Header - minimal, modern, non destructive
   Activated when body has class "has-modern-sidebar" and a .nova-header is injected.
   The legacy <header> (if any) is hidden visually but kept in DOM so its
   existing IDs/handlers (lock-button, logout-button, KYC, etc.) keep working.
*/

/* Masque tout header legacy, peu importe sa profondeur dans le DOM,
   sauf les éléments internes du Nova Header (.header-content / .header-actions / etc.) */
body.has-modern-sidebar header:not(.nova-header):not(.nova-header *),
body.has-modern-sidebar .bo-header:not(.nova-header):not(.nova-header *),
body.has-modern-sidebar .cp-header:not(.nova-header):not(.nova-header *),
body.has-modern-sidebar .topbar:not(.nova-header):not(.nova-header *),
body.has-modern-sidebar .header:not(.nova-header):not(.header-content):not(.header-actions):not(.header-brand):not(.nova-header *) {
  display: none !important;
}

html body.has-modern-sidebar {
  padding-top: 60px !important;
}

@media (max-width: 640px) {
  html body.has-modern-sidebar {
    padding-top: 52px !important;
  }
}

.nova-header {
  height: 60px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  position: fixed;
  top: 0;
  left: var(--app-sidebar-w, 248px);
  right: 0;
  z-index: 1300;
  color: #e2e8f0;
  animation: novaHeaderIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes novaHeaderIn {
  0% {
    opacity: 0;
    transform: translateY(-22px);
  }
  60% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .nova-header {
    animation: none;
  }
}

.nova-header .header-content {
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 0.65rem;
}

.nova-header .search-container {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 36rem;
}

.nova-header .search-input-wrapper {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 9999px;
  padding: 0.35rem 0.85rem;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.nova-header .search-input-wrapper:focus-within {
  border-color: #22d3ee;
  background: rgba(34, 211, 238, 0.07);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.14);
}

.nova-header .search-input-wrapper i,
.nova-header .search-input-wrapper svg {
  width: 14px;
  height: 14px;
  color: #94a3b8;
  flex: 0 0 auto;
}

.nova-header .search-input {
  background: transparent;
  border: 0;
  outline: none;
  flex: 1;
  min-width: 0;
  margin-left: 0.55rem;
  font-size: 0.82rem;
  color: #f8fafc;
}

.nova-header .search-input::placeholder {
  color: #94a3b8;
}

.nova-header .search-icon-btn {
  display: none;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  cursor: pointer;
}

.nova-header .header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  flex: 0 0 auto;
}

.nova-header .new-op-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  background: linear-gradient(135deg, #06b6d4 0%, #9333ea 100%);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.78rem;
  border: 0;
  border-radius: 9999px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(6, 182, 212, 0.25);
  transition: transform 0.18s ease, box-shadow 0.2s ease, filter 0.2s ease;
  white-space: nowrap;
}

.nova-header .new-op-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(147, 51, 234, 0.32);
  filter: brightness(1.06);
}

.nova-header .new-op-btn:active {
  transform: translateY(0);
}

.nova-header .new-op-btn i,
.nova-header .new-op-btn svg {
  width: 14px;
  height: 14px;
}

.nova-header .icon-btn {
  position: relative;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.nova-header .icon-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.nova-header .icon-btn:active {
  transform: scale(0.92);
}

.nova-header .icon-btn i,
.nova-header .icon-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.nova-header .icon-btn .badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #e11d48;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  line-height: 1;
  border: 2px solid #0f172a;
  box-shadow: 0 2px 6px rgba(225, 29, 72, 0.45);
}

.nova-header .profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.5rem 0.25rem 0.3rem;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 9999px;
  cursor: pointer;
  color: #e2e8f0;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.nova-header .profile-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.10);
}

.nova-header .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22d3ee, #a855f7);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  box-shadow: 0 2px 6px rgba(34, 211, 238, 0.25);
}

.nova-header .profile-info {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  text-align: left;
  max-width: 130px;
}

.nova-header .profile-info .name {
  font-size: 0.76rem;
  font-weight: 600;
  color: #f8fafc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nova-header .profile-info .role {
  font-size: 0.64rem;
  color: #94a3b8;
  text-transform: capitalize;
}

.nova-header .profile-chevron {
  width: 12px;
  height: 12px;
  color: #94a3b8;
  transition: transform 0.2s ease;
}

.nova-header.profile-open .profile-chevron {
  transform: rotate(180deg);
  color: #22d3ee;
}

/* --- Profile dropdown --- */
.nova-header .profile-dropdown {
  position: relative;
}

.nova-header .profile-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 240px;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.55);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  z-index: 1400;
}

.nova-header.profile-open .profile-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.nova-header .profile-menu-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  margin-bottom: 6px;
}

.nova-header .avatar.avatar-lg {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1rem;
}

.nova-header .profile-menu-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f8fafc;
  line-height: 1.2;
}

.nova-header .profile-menu-role {
  font-size: 0.74rem;
  color: #94a3b8;
  margin-top: 2px;
}

.nova-header .profile-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: #e2e8f0;
  font-size: 0.86rem;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.nova-header .profile-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.nova-header .profile-menu-item i,
.nova-header .profile-menu-item svg {
  width: 16px;
  height: 16px;
  color: #94a3b8;
}

.nova-header .profile-menu-item:hover i,
.nova-header .profile-menu-item:hover svg {
  color: #22d3ee;
}

.nova-header .profile-menu-divider {
  height: 1px;
  background: rgba(148, 163, 184, 0.14);
  margin: 6px 4px;
}

.nova-header .profile-menu-logout {
  color: #fca5a5;
}

.nova-header .profile-menu-logout:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
}

.nova-header .profile-menu-logout i,
.nova-header .profile-menu-logout svg {
  color: #fca5a5;
}

.nova-header .profile-menu-logout:hover i,
.nova-header .profile-menu-logout:hover svg {
  color: #fecaca;
}

.nova-header .nova-burger {
  display: none;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  border-radius: 10px;
  cursor: pointer;
}

@media (max-width: 1024px) {
  .nova-header {
    left: 0;
  }

  .nova-header .nova-burger {
    display: inline-flex;
  }

  .nova-header .icon-btn i,
  .nova-header .icon-btn svg {
    width: 18px;
    height: 18px;
  }

  .nova-header .icon-btn .badge {
    min-width: 16px;
    height: 16px;
    font-size: 9px;
    top: -2px;
    right: -2px;
  }

  .nova-header .header-content {
    padding: 0 0.9rem;
    gap: 0.65rem;
  }

  .nova-header .search-container {
    display: none;
  }

  .nova-header .search-icon-btn {
    display: inline-flex;
  }

  .nova-header.search-open .search-container {
    display: block;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    max-width: 100%;
  }

  .nova-header .new-op-label {
    display: none;
  }

  .nova-header .new-op-btn {
    padding: 0.45rem 0.7rem;
  }

  .nova-header .profile-info,
  .nova-header .profile-chevron {
    display: none;
  }
}

@media (max-width: 640px) {
  .nova-header {
    height: 52px;
  }

  .nova-header .header-actions {
    gap: 0.3rem;
  }

  .nova-header .avatar {
    width: 26px;
    height: 26px;
    font-size: 0.68rem;
  }
}

/* --- Z-index harmonization on mobile ---
   On mobile, the sidebar is a temporary off-canvas panel and must overlay
   the fixed Nova Header. Promote sidebar + overlay above the header.
*/
@media (max-width: 1024px) {
  body.has-modern-sidebar nav {
    z-index: 1450 !important;
  }
  body.has-modern-sidebar .app-sidebar-overlay {
    z-index: 1400 !important;
  }
  .nova-header {
    z-index: 1300;
  }
  .nova-header .profile-menu {
    z-index: 1350;
  }
}

/* --- Nova toast (fallback notifications) --- */
.nova-toast {
  position: fixed;
  top: 76px;
  right: 20px;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #f8fafc;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.85rem;
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.4);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1500;
}
.nova-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   Hard-reset contre les CSS legacy (header.css, etc.) qui
   ciblent l'élément <header> ou .header-actions sans scope.
   Garantit que .nova-header se comporte de la même manière sur
   toutes les pages, y compris index.html.
   ============================================================ */
header.nova-header {
  padding: 0 !important;
  min-width: 0 !important;
  width: auto !important;
  margin: 0 !important;
  background-color: rgba(15, 23, 42, 0.88) !important;
  box-shadow: none !important;
  display: block !important;
  justify-content: initial !important;
  gap: 0 !important;
  align-items: initial !important;
  overflow: visible !important;
}

.nova-header .header-content {
  display: flex !important;
  align-items: center !important;
  padding: 0 1rem !important;
  gap: 0.65rem !important;
  width: 100% !important;
  height: 100% !important;
}

.nova-header .header-actions {
  display: flex !important;
  align-items: center !important;
  gap: 0.4rem !important;
  margin-left: auto !important;
  flex: 0 0 auto !important;
}

.nova-header .header-actions button,
.nova-header .header-actions a.new-op-btn {
  font-family: inherit;
}

.nova-header .header-actions .icon-btn,
.nova-header .header-actions .profile-btn {
  padding: 0 !important;
  color: #94a3b8 !important;
  background-color: transparent !important;
}

.nova-header .header-actions .icon-btn {
  width: 32px !important;
  height: 32px !important;
}

.nova-header .header-actions .profile-btn {
  padding: 0.25rem 0.5rem 0.25rem 0.3rem !important;
  color: #e2e8f0 !important;
}

.nova-header .header-actions .new-op-btn {
  padding: 0.4rem 0.85rem !important;
  color: #ffffff !important;
}
