/* Navigation Bar */
:root {
  --sidebar-width: 280px;
  --header-height: 64px;
  --transition-speed: 0.3s;
  --radius-md: 8px;
  --primary: #163988;
  --primary-light: #e0e7ff;
  --danger: #ef4444;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --background: #f9fafb;
  --card: #ffffff;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
}

/* Dark mode variables */
@media (prefers-color-scheme: dark) {
  :root {
    --text: #f3f4f6;
    --text-muted: #9ca3af;
    --border: #374151;
    --background: #111827;
    --card: #1f2937;
    --gray-100: #374151;
    --gray-200: #4b5563;
    --gray-600: #d1d5db;
    --gray-700: #e5e7eb;
    --gray-800: #f3f4f6;
  }
}

.navbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.navbar .container {
  max-width: 100%;
  padding: 0 1.5rem;
  margin: 0 auto;
}

.navbar-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  transition: color 0.2s ease;
}

.brand .brand-text {
  display: inline-flex;
  flex-direction: column;
  line-height: 1;
  margin-left: 0.25rem;
}

.brand .brand-text .brand-sub {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  display: block;
  margin-top: -3px;
}

.brand .logo {
  height: 76px;
  width: auto;
  display: block;
}

@media (max-width: 1024px) {
  /* Hide the brand text on tablet/mobile so the hamburger sits immediately right of the logo */
  .brand .brand-text {
    display: none;
  }
}

.brand:hover {
  color: var(--primary);
}

.brand .icon {
  font-size: 1.5rem;
  color: var(--primary);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  color: var(--text);
}

.user-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--gray-100);
  color: var(--text);
}

.btn-icon i {
  font-size: 1.1rem;
}

/* Mobile menu button (always visible now to unify toggles) */
.mobile-menu-button {
  display: inline-flex;
  margin-left: 0.5rem;
}

@media (max-width: 1024px) {
  .mobile-menu-button {
    display: inline-flex;
  }
  /* on tablets and smaller, hide the brand text for compact layout */
  .brand-middle-cell .brand-text-link {
    display: none;
  }
  /* make sure user-cell stays right-aligned and does not wrap */
  .brand-user-cell { min-width: 120px; }
  /* Reset navbar-table margins on narrow viewports (no sidebar space) */
  .navbar-table { margin-left: 0; width: 100%; }
}

/* Collapsed (icon-only) state for desktop */
.sidebar.collapsed {
  width: 64px;
  overflow: visible;
}
.sidebar.collapsed .sidelink {
  justify-content: center;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}
.sidebar.collapsed .sidelink > span {
  display: none;
  width: 0;
  opacity: 0;
}
.sidebar.collapsed .sidebar-section-title {
  display: none;
}
.sidebar.collapsed .notification-badge {
  display: none;
}
.sidebar.collapsed .icon {
  margin-right: 0;
}

.sidebar-header {
  padding: 0 1.5rem 1rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0;
}

.sidebar-toggle {
  cursor: pointer;
  transition: transform 0.2s ease;
}

.sidebar-toggle:hover {
  color: var(--primary);
}

.sidebar-section {
  margin-bottom: 1.5rem;
}

.sidebar-section:last-child {
  margin-bottom: 0;
}

.sidebar-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 1.5rem;
  margin: 1.5rem 0 0.75rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0 0.5rem;
}

.sidelink {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  margin: 0 0.5rem;
  border-radius: var(--radius-md);
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

.sidelink:hover {
  background: var(--gray-100);
  color: var(--primary);
}

.sidelink.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.sidelink .icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  opacity: 0.9;
}

.sidelink.active .icon {
  opacity: 1;
}

.notification-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  position: relative;
}

.notification-badge {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.4rem;
}

/* Main Content */
.content {
  flex: 1;
  padding: 1.5rem 2rem;
  background: var(--background);
  min-height: calc(100vh - 64px);
}

/* Mobile menu overlay */
.menu-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 80;
  opacity: 0;
  transition: opacity 0.3s ease;
}

body.menu-open .menu-overlay {
  display: block;
  opacity: 1;
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: 0;
    transform: translateX(-100%);
    z-index: 90;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    transition: transform var(--transition-speed) ease, width var(--transition-speed) ease;
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .content {
    padding: 1.25rem;
  }
}

/* Active state for sidebar links */
.sidebar-nav a.router-link-active,
.sidebar-nav a[aria-current="page"] {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

/* Focus states for better accessibility */
.sidelink:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .sidelink:hover {
    background: var(--gray-800);
  }
  
  .sidelink.active {
    background: rgba(99, 102, 241, 0.15);
  }
  
  .btn-icon:hover {
    background: var(--gray-800);
  }
}
