:root {
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-terminal: #020617;
  --bg-lighter: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-glow: rgba(99,102,241,0.4);
  --border-color: #334155;
  --glass-bg: rgba(15,23,42,0.85);
}

:root.light {
  --bg-dark: #ffffff;
  --bg-card: #f8fafc;
  --bg-terminal: #f1f5f9;
  --bg-lighter: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #475569;
  --primary: #6366f1;
  --primary-glow: rgba(99,102,241,0.4);
  --border-color: #cbd5e1;
  --glass-bg: rgba(255,255,255,0.95);
}

/* Main Navigation Bar */
nav,
nav.main-header {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  height: 70px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
  display: flex;
  align-items: center;
}

nav .nav-content,
nav.main-header .nav-content {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 2rem;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Logo */
.logo {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.logo-icon {
  width: 35px;
  height: 35px;
  object-fit: contain;
}

/* Navigation Links */
.nav-links {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  justify-content: center;
  gap: 24px;
}

.nav-links a {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-main);
}

/* Right Navigation Section */
.nav-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

/* Primary Button */
.btn-primary {
  background: var(--primary);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px var(--primary-glow);
  transition: all 0.3s;
  font-family: inherit;
}

.btn-primary:hover {
  transform: translateY(-2px);
  background: #4f46e5;
}

/* Profile Avatar */
.profile-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid var(--border-color);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.profile-avatar:hover {
  box-shadow: 0 0 0 2px var(--primary);
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Profile Menu Dropdown */
.profile-menu {
  position: absolute;
  top: 70px;
  right: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  min-width: 250px;
  z-index: 1001;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.profile-menu-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.profile-menu-name {
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.95rem;
}

.profile-menu-email {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.profile-menu-item {
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  color: var(--text-main);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s;
  border-bottom: 1px solid var(--border-color);
}

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

.profile-menu-item:hover {
  background: var(--primary-glow);
}

.profile-menu-logout {
  color: var(--accent-red, #f87171);
}

.profile-menu-logout:hover {
  background: rgba(248, 113, 113, 0.1);
}

.profile-menu-item i {
  width: 16px;
  text-align: center;
}

/* Legacy support */
.profile-menu.active,
.profile-menu[style*="display: block"] {
  display: block;
}

.profile-menu > div,
.profile-info {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.profile-menu a {
  display: block;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  text-decoration: none;
  transition: background 0.2s;
}

.profile-menu a:hover {
  background: var(--primary-glow);
}

.profile-menu button {
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  color: var(--text-main);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}

.profile-menu button:hover {
  background: var(--primary-glow);
}

/* Theme Toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

#themeLabel {
  font-size: 0.85rem;
  color: var(--text-muted);
  user-select: none;
}

.theme-switch {
  position: relative;
  width: 50px;
  height: 26px;
  cursor: pointer;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  cursor: pointer;
}

.theme-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-lighter);
  border-radius: 26px;
  transition: background 0.3s;
  display: flex;
  align-items: center;
  padding: 0 3px;
}

.theme-slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s;
}

.theme-switch input:checked + .theme-slider {
  background: var(--primary);
}

.theme-switch input:checked + .theme-slider::before {
  transform: translateX(24px);
}

/* Responsive Design */
/* Reduce spacing for 1440px screens */
@media (max-width: 1440px) {
  .nav-links {
    gap: 20px;
  }
  
  .nav-links a {
    font-size: 0.9rem;
  }
  
  .nav-right {
    gap: 12px;
  }
}

/* Further reduce spacing for 1024px screens */
@media (max-width: 1024px) {
  .nav-links {
    gap: 16px;
  }
  
  .nav-links a {
    font-size: 0.85rem;
  }
  
  .logo {
    font-size: 1.3rem;
  }
  
  .nav-right {
    gap: 10px;
  }
}

@media (max-width: 600px) {
  .nav-links {
    position: fixed;
    top: 70px;
    left: 0;
    width: 100%;
    height: calc(100vh - 70px);
    background: var(--bg-dark);
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 2rem;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    z-index: 999;
    display: flex; /* Override display:none if set elsewhere */
    gap: 0;
  }

  .nav-links.active {
    transform: translateX(0);
  }

  .nav-dropdown {
    width: 100%;
  }

  .nav-dropdown-btn {
    width: 100%;
    font-size: 1.2rem;
    padding: 1.5rem;
    justify-content: center;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
  }

  .nav-dropdown-content {
    position: static;
    display: block;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    background: var(--bg-card);
    border: none;
    padding: 0;
  }

  .nav-dropdown-content a {
    padding: 1rem;
    font-size: 1rem;
    background: rgba(255,255,255,0.02);
  }

  .nav-links a {
    font-size: 1.2rem;
    margin: 0;
    padding: 1.5rem;
    width: 100%;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
  }
  
  .nav-links a:hover {
    background: var(--bg-card);
  }
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background: var(--bg-lighter);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1.1rem;
}

.theme-toggle-btn:hover {
  background: var(--primary-glow);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.theme-toggle-btn i {
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-toggle-btn:active i {
  transform: scale(0.8);
}

/* Nav Dropdown */
.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.nav-dropdown-btn:hover,
.nav-dropdown-btn.active {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-dropdown-content {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  min-width: 160px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1000;
  padding: 8px;
}

.nav-dropdown:hover .nav-dropdown-content {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(5px);
}

.nav-dropdown-content a {
  display: block;
  padding: 10px 16px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.2s ease;
  text-align: left;
  font-size: 0.9rem;
}

.nav-dropdown-content a:hover {
  background: rgba(99, 102, 241, 0.1);
  color: var(--text-main);
  padding-left: 20px;
}

/* Mobile Menu Button */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 5px;
  z-index: 1001;
}

@media (max-width: 600px) {
  .mobile-menu-btn {
    display: block;
  }
}

/* Move theme toggle into profile menu on very small screens */
@media (max-width: 425px) {
  /* Hide inline theme toggles elsewhere; show only the one inside profile menu */
  .theme-toggle { display: none !important; }
  .profile-theme-toggle .theme-toggle { display: flex !important; }
  /* Show profile menu theme control */
  .profile-theme-toggle { display: block !important; }
  /* Make profile menu slightly wider on mobile */
  .profile-menu { min-width: 220px; right: 10px; }
}
