/* ============================================
   Redas - Reusable Navigation Styles
   Consolidated from dashboard.css nav sections.
   Include this alongside nav.js for standalone nav.
   Uses CSS custom properties from dashboard.css.
   ============================================ */

/* ============================================
   Page Navigation Header (Sub-pages)
   Height: 56px, sticky, flex layout
   ============================================ */
.page-nav {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0 var(--space-lg);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.page-nav-left {
  display: flex;
  align-items: center;
}

.page-nav-back {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  transition: all 0.2s;
}

.page-nav-back:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.page-nav-back svg {
  width: 18px;
  height: 18px;
}

.page-nav-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.page-nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.page-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--border-radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s;
  background: transparent;
  border: none;
  cursor: pointer;
}

.page-nav-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.page-nav-icon svg {
  width: 20px;
  height: 20px;
}

/* ============================================
   Top Navigation Bar (Dashboard)
   Height: 64px, sticky, flex layout
   ============================================ */
.top-nav {
  background: var(--bg-header, #1a2332);
  color: #f1f5f9;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 0 var(--space-lg);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

/* ============================================
   Search Container (Left side of top-nav)
   ============================================ */
.nav-search-container {
  flex-shrink: 0;
}

.global-search {
  position: relative;
  width: 220px;
}

.global-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  pointer-events: none;
}

.global-search .search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  background: rgba(255,255,255,0.06);
  color: #f1f5f9;
  transition: all 0.2s;
}

.global-search .search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: rgba(255,255,255,0.1);
  box-shadow: 0 0 0 3px rgba(232, 119, 34, 0.15);
}

.global-search .search-input::placeholder {
  color: #64748b;
}

/* ============================================
   Search Results Dropdown
   ============================================ */
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 360px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 1000;
}

.search-results-loading {
  padding: 16px;
  text-align: center;
  color: var(--text-secondary);
}

/* ============================================
   Navigation Tabs (Center of top-nav)
   ============================================ */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-tab {
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #94a3b8;
  text-decoration: none;
  border-radius: var(--border-radius);
  transition: all 0.15s;
}

.nav-tab:hover {
  color: #f1f5f9;
  background: rgba(255,255,255,0.08);
}

.nav-tab.active {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

/* ============================================
   Nav Right Section (icon buttons, upload)
   ============================================ */
.nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.nav-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius);
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  text-decoration: none;
}

.nav-icon-btn:hover {
  background: rgba(255,255,255,0.08);
  color: #f1f5f9;
}

/* ============================================
   Upload Button (in top-nav right)
   ============================================ */
.btn-upload {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
}

/* ============================================
   Notification Badge
   ============================================ */
.notification-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 18px;
  height: 18px;
  background: var(--color-danger);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ============================================
   Notification Dropdown
   ============================================ */
.notification-dropdown {
  position: relative;
}

.notification-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-height: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
}

.notification-dropdown-menu.show {
  display: flex;
}

.notification-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  color: var(--text-primary);
}

.notification-mark-all {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 0.8125rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--border-radius-sm);
}

.notification-mark-all:hover {
  background: var(--bg-hover);
}

.notification-dropdown-list {
  flex: 1;
  overflow-y: auto;
  max-height: 360px;
}

.notification-loading,
.notification-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
}

.notification-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.15s;
}

.notification-item:last-child {
  border-bottom: none;
}

.notification-item:hover {
  background: var(--bg-hover);
}

.notification-item.unread {
  background: rgba(232, 119, 34, 0.05);
}

.notification-item.unread:hover {
  background: rgba(232, 119, 34, 0.1);
}

.notification-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-secondary, var(--bg-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.notification-item.unread .notification-icon {
  background: var(--color-primary);
  color: white;
}

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

.notification-title {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notification-body {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notification-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.notification-dropdown-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.notification-dropdown-footer a {
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.notification-dropdown-footer a:hover {
  text-decoration: underline;
}

/* ============================================
   Theme Toggle Icons (sun/moon)
   ============================================ */
.sun-icon,
.moon-icon {
  transition: opacity 0.2s;
}

/* ============================================
   User Avatar + Dropdown
   ============================================ */
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  margin-left: var(--space-sm);
}

.user-dropdown {
  position: relative;
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: var(--space-sm);
  display: none;
  z-index: 1000;
}

.user-dropdown-menu.show {
  display: block;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.875rem;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.user-dropdown-item:hover {
  background: var(--bg-hover);
}

.user-dropdown-item.danger {
  color: var(--color-danger);
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--space-sm) 0;
}

/* ============================================
   Mobile hamburger + active label (hidden on desktop)
   ============================================ */
.nav-mobile-left {
  display: none;
  align-items: center;
  gap: 8px;
}

.hamburger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: var(--border-radius-sm, 6px);
  -webkit-tap-highlight-color: transparent;
}

.hamburger-btn:active {
  background: var(--bg-hover);
}

.nav-active-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ============================================
   Mobile drawer + backdrop
   ============================================ */
.nav-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  opacity: 0;
  transition: opacity 200ms ease;
}

.nav-drawer-backdrop.open {
  display: block;
  opacity: 1;
}

.nav-drawer {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 80vw;
  background: var(--bg-card);
  z-index: 201;
  transform: translateX(-100%);
  transition: transform 200ms ease;
  flex-direction: column;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

.nav-drawer.open {
  transform: translateX(0);
}

.nav-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.nav-drawer-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
}

.nav-drawer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: var(--border-radius-sm, 6px);
}

.nav-drawer-close:active {
  background: var(--bg-hover);
}

.nav-drawer-items {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.nav-drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  min-height: 48px;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-drawer-item:active {
  background: var(--bg-hover);
}

.nav-drawer-item.active {
  color: var(--color-primary);
  background: var(--color-primary-light, rgba(232, 119, 34, 0.08));
  font-weight: 600;
}

.drawer-inbox-badge {
  min-width: 20px;
  height: 20px;
  background: var(--color-danger);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  margin-left: auto;
}

/* ============================================
   Responsive: Mobile (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {
  .top-nav {
    padding: 0 4px 0 0;
  }

  /* Show hamburger + active label, hide desktop logo */
  .nav-mobile-left {
    display: flex;
  }
  .nav-logo {
    display: none;
  }
  .nav-logo-mobile {
    display: flex;
  }

  /* Hide search and horizontal tabs */
  .nav-search-container {
    display: none;
  }
  .nav-tabs {
    display: none;
  }

  /* Show drawer (it's hidden via transform until .open) */
  .nav-drawer {
    display: flex;
  }

  /* Icon-only upload button */
  .btn-upload {
    padding: 8px;
    gap: 0;
    font-size: 0;
  }
  .btn-upload svg {
    margin: 0;
  }

  /* Shrink nav-right gap */
  .nav-right {
    gap: 2px;
  }

  .nav-icon-btn {
    width: 44px;
    height: 44px;
  }

}

/* ============================================
   Responsive: Small mobile (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {
  .notification-dropdown-menu {
    position: fixed;
    top: 60px;
    right: 8px;
    left: 8px;
    width: auto;
    max-height: calc(100vh - 80px);
  }

  .user-dropdown-menu {
    position: fixed;
    top: 60px;
    right: 8px;
    width: auto;
    min-width: 180px;
  }

  /* Page nav adjustments */
  .page-nav {
    padding: 0 var(--space-md, 12px);
  }

  .page-nav-back span {
    display: none;
  }

  .page-nav-center {
    font-size: 0.9375rem;
  }
}
