/* =========================================
   Navbar Modern (Glassmorphism & RTL)
   ========================================= */

.navbar-modern {
  position: sticky;
  top: 0;
  z-index: var(--z-navbar);
  height: var(--navbar-height);
  width: 100%;

  background-color: var(--navbar-bg);
  backdrop-filter: blur(var(--navbar-backdrop-blur));
  -webkit-backdrop-filter: blur(var(--navbar-backdrop-blur));

  border-bottom: 1px solid var(--navbar-border-color);
  transition: all var(--transition-normal);

  /* Padding matches the container logic */
  padding-inline: 1.5rem;
}

.navbar-container {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 1. Left Section (Brand/Context/Toggle) */
.navbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.navbar-toggle {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--navbar-icon-color);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--border-radius-sm);
  transition:
    color var(--transition-fast),
    background var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.navbar-toggle:hover {
  color: var(--navbar-icon-hover);
  background-color: rgba(0, 0, 0, 0.05);
}

.context-title {
  color: var(--navbar-text);
  font-weight: 600;
  font-size: 1.1rem;
}

/* 2. Center Section (Search) */
.navbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 600px;
}

/* 3. Right Section (Actions) */
.navbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-action-item {
  position: relative;
}

.action-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--navbar-icon-color);
  font-size: 1.25rem;
  /* Icon size */
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.action-btn:hover,
.action-btn.show {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--navbar-icon-hover);
}

/* Language Button Special Styling */
.lang-btn {
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid var(--navbar-border-color);
  width: auto;
  padding-inline: 0.75rem;
}

/* Notification Badge Pulse */
.notification-hub {
  position: relative;
}

.badge-pulse {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  width: 8px;
  height: 8px;
  background-color: var(--danger-color, #ef4444);
  border-radius: 50%;
  border: 2px solid #fff;
  animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }

  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }

  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* 4. User Profile Dropdown */
.user-btn {
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--border-radius-pill);
  transition: background var(--transition-fast);
}

.user-btn:hover,
.user-btn.show {
  background-color: rgba(0, 0, 0, 0.05);
}

.avatar-wrapper {
  width: 36px;
  height: 36px;
  background-color: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
  text-align: start;
  /* Logical property */
}

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--navbar-text);
}

.user-role {
  font-size: 0.75rem;
  color: #64748b;
}

/* 5. Dropdown Menus (General Modern Polish) */
.dropdown-menu {
  border: none;
  box-shadow:
    0 10px 25px -5px rgba(0, 0, 0, 0.1),
    0 8px 10px -6px rgba(0, 0, 0, 0.1);
  border-radius: var(--border-radius-lg);
  padding: 0.5rem;
  margin-top: 0.5rem !important;
  /* Override bootstrap popper offset sometimes */
  min-width: 240px;
}

.dropdown-item {
  border-radius: var(--border-radius-sm);
  padding: 0.5rem 1rem;
  font-weight: 500;
  color: var(--navbar-text);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dropdown-item:hover {
  background-color: var(--primary-light);
  color: var(--primary-dark);
}

.dropdown-item i {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
}

/* Notification Dropdown Specifics */
.notification-dropdown {
  width: 100%;
  max-width: 320px;
  padding: 0;
}

/* Notification Panel (Offcanvas) */
.notification-panel {
  --bs-offcanvas-width: 380px;
}

.notification-panel .offcanvas-body {
  display: flex;
  flex-direction: column;
  padding: 0;
}

.notification-panel .notification-list {
  flex: 1;
  overflow-y: auto;
  max-height: calc(100vh - 200px);
}

.notification-panel .notification-actions {
  background-color: var(--bs-tertiary-bg, #f8f9fa);
}

/* Notification Item Styling */
.notification-panel .notification-item {
  display: flex;
  align-items: flex-start;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid
    var(--bs-border-color-translucent, rgba(0, 0, 0, 0.1));
  text-decoration: none;
  color: inherit;
  transition: background-color 0.15s ease;
}

.notification-panel .notification-item:hover {
  background-color: var(--bs-tertiary-bg, #f8f9fa);
}

.notification-panel .notification-item.unread {
  background-color: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.05);
  border-inline-start: 3px solid var(--bs-primary, #0d6efd);
}

.notification-panel .notification-item .notif-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bs-tertiary-bg, #f8f9fa);
  flex-shrink: 0;
  margin-inline-end: 0.75rem;
}

.notification-panel .notification-item .notif-content {
  flex: 1;
  min-width: 0;
}

.notification-panel .notification-item .notif-title {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
  color: var(--bs-body-color);
}

.notification-panel .notification-item.unread .notif-title {
  font-weight: 700;
}

.notification-panel .notification-item .notif-meta {
  font-size: 0.8rem;
  color: var(--bs-secondary-color, #6c757d);
  display: block;
  margin-bottom: 0.25rem;
}

.notification-panel .notification-item .notif-time {
  font-size: 0.75rem;
  color: var(--bs-secondary-color, #6c757d);
}

.notification-panel .notification-item .notif-priority {
  flex-shrink: 0;
  margin-inline-start: 0.5rem;
}

.notification-panel .notification-empty {
  padding: 2rem;
  text-align: center;
}

.notification-panel .notification-footer {
  background-color: var(--bs-tertiary-bg, #f8f9fa);
  border-top: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.1));
}

/* Profile Menu Specifics */
.profile-menu {
  min-width: 200px;
  max-width: 280px;
}

.dropdown-header {
  padding: 1rem;
  border-bottom: 1px solid var(--navbar-border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notification-list {
  max-height: 300px;
  overflow-y: auto;
}

.notification-item {
  display: flex;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
  text-decoration: none;
  color: var(--navbar-text);
  transition: background var(--transition-fast);
}

.notification-item:hover {
  background-color: #f8fafc;
}

.notif-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-inline-end: 1rem;
  flex-shrink: 0;
}

.notif-icon.success {
  color: var(--success-color);
  background-color: #d1fae5;
}

.notif-icon.info {
  color: var(--primary-color);
  background-color: var(--primary-light);
}

.notif-content {
  flex: 1;
}

.notif-title {
  margin: 0;
  font-weight: 600;
  font-size: 0.9rem;
}

.notif-meta {
  font-size: 0.75rem;
  color: #64748b;
}

.dropdown-footer {
  padding: 0.75rem;
  text-align: center;
  border-top: 1px solid var(--navbar-border-color);
  display: flex;
  justify-content: space-between;
}

/* Offcanvas Panels (Notifications/Profile) */
.navbar-offcanvas {
  --bs-offcanvas-width: 340px;
  background-color: #ffffff;
  color: var(--navbar-text);
  border-inline-start: 1px solid var(--navbar-border-color);
  z-index: 1060;
}

.offcanvas-backdrop {
  z-index: 1055;
}

.navbar-offcanvas .offcanvas-header {
  border-bottom: 1px solid var(--navbar-border-color);
}

.panel-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.notification-panel .notification-list {
  max-height: calc(100vh - 220px);
}

.notification-footer {
  padding-top: 0.75rem;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--navbar-border-color);
}

.profile-summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--navbar-border-color);
  margin-bottom: 1rem;
}

.profile-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.user-email {
  font-size: 0.8rem;
  color: #64748b;
}

[dir="rtl"] .navbar-offcanvas.offcanvas-end {
  left: 0;
  right: auto;
  transform: translateX(-100%);
}

[dir="rtl"] .navbar-offcanvas.offcanvas-end.show {
  transform: none;
}

/* Empty State */
.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: #94a3b8;
}

.empty-state i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  display: block;
}

/* Animations */
.animate {
  animation-duration: 0.2s;
  animation-fill-mode: both;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================
   Responsive Fixes (Mobile Dropdowns)
   ========================================= */
@media (max-width: 575.98px) {
  /* Base dropdown adjustments */
  .dropdown-menu {
    position: fixed !important;
    inset-inline-end: 0.5rem !important;
    inset-inline-start: 0.5rem !important;
    top: var(--navbar-height, 60px) !important;
    width: auto !important;
    max-width: calc(100vw - 1rem) !important;
    min-width: auto !important;
    margin: 0 !important;
    transform: none !important;
  }

  /* Notification dropdown - full width on mobile */
  .notification-dropdown {
    inset-inline-start: 0 !important;
    inset-inline-end: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
  }

  .notification-list {
    max-height: calc(100vh - 180px);
  }

  /* Profile dropdown - right-aligned with margin */
  .profile-menu {
    inset-inline-start: auto !important;
    inset-inline-end: 0.5rem !important;
    width: auto !important;
    min-width: 220px !important;
    max-width: calc(100vw - 1rem) !important;
    border-radius: var(--border-radius-lg) !important;
  }

  /* Ensure content inside doesn't overflow */
  .dropdown-item {
    white-space: normal;
  }

  .navbar-offcanvas {
    --bs-offcanvas-width: 100%;
  }
}

/* Extra small devices */
@media (max-width: 359.98px) {
  .profile-menu {
    min-width: 180px !important;
  }
}

/* ============================================================
   Navbar Entity Switcher (Phase 4 — moved from sidebar)
   Scoped under .navbar-entity-switcher so sidebar variant CSS
   in components/sidebar.css remains untouched.
   ============================================================ */
.navbar-entity-switcher {
  display: flex;
  align-items: center;
  margin-inline-start: 0.75rem;
}

.navbar-entity-switcher .role-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 200px;
  max-width: 280px;
  height: 38px;
  padding-inline: 0.65rem;
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
  border-radius: 999px;
  background: var(--surface-2, #fff);
  color: var(--text-color, inherit);
  font-size: 0.85rem;
  line-height: 1.1;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
  cursor: pointer;
}

.navbar-entity-switcher .role-dropdown-toggle:hover,
.navbar-entity-switcher .role-dropdown-toggle:focus-visible {
  background: var(--surface-3, #f3f4f6);
  border-color: var(--border-color-strong, rgba(0, 0, 0, 0.16));
  outline: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.navbar-entity-switcher .entity-identity-pill {
  cursor: default;
}

.navbar-entity-switcher .role-icon-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
}

.navbar-entity-switcher .role-icon-wrapper i {
  font-size: 0.85rem;
}

.navbar-entity-switcher .role-name {
  flex: 1 1 auto;
  min-width: 0;
  text-align: start;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.navbar-entity-switcher .role-name .entity-subtitle {
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.7;
  line-height: 1;
  margin-top: 1px;
}

.navbar-entity-switcher .dropdown-arrow {
  font-size: 0.7rem;
  opacity: 0.6;
  margin-inline-start: auto;
  flex-shrink: 0;
}

.navbar-entity-switcher .role-dropdown-menu {
  min-width: 280px;
  max-width: 360px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.35rem;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

.navbar-entity-switcher .role-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-block: 0.5rem;
  padding-inline: 0.65rem;
  border-radius: 8px;
  border: 0;
  background: transparent;
  text-align: start;
  white-space: normal;
}

.navbar-entity-switcher .role-dropdown-item:hover,
.navbar-entity-switcher .role-dropdown-item:focus-visible {
  background: var(--surface-3, #f3f4f6);
}

.navbar-entity-switcher .role-dropdown-item.active {
  background: var(--brand-tint, rgba(13, 110, 253, 0.08));
  color: var(--brand-color, inherit);
}

.navbar-entity-switcher .role-dropdown-item .role-name {
  white-space: normal;
  overflow: visible;
}

/* Tablet — shrink the trigger to icon + short label. */
@media (max-width: 991.98px) {
  .navbar-entity-switcher .role-dropdown-toggle {
    min-width: 56px;
    max-width: 180px;
  }
  .navbar-entity-switcher .role-name .entity-subtitle {
    display: none !important;
  }
}

/* Mobile-fallback inside the user offcanvas — full width. */
.profile-actions .navbar-entity-switcher {
  margin-inline-start: 0;
  width: 100%;
}

.profile-actions .navbar-entity-switcher .role-dropdown,
.profile-actions .navbar-entity-switcher .role-dropdown-toggle {
  width: 100%;
  max-width: none;
}
