/* assets/css/components/navbar.css */

/* Ensure theme variables are accessible if not imported globally */
/* These should ideally come from main.css, but defining here as fallback */
:root {
  --dark: #0a192f;
  --dark-light: #112240;
  --light: #ccd6f6;
  --light-dark: #8892b0;
  --primary: #64ffda;
  --transition: all 0.25s cubic-bezier(0.645, 0.045, 0.355, 1);
  --font-main: 'Calibre', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
  /* Define navbar specific background color variable */
  --navbar-bg: rgba(10, 25, 47, 0.85); /* Default dark navbar bg */
}

/* Light theme navbar background */
html[data-theme='light'] {
  --navbar-bg: rgba(255, 255, 255, 0.95); /* Nearly white, slightly transparent */
  /* Ensure text colors are defined here or inherited from main.css */
  /* main.css should define --text-main and --text-secondary */
}

/* --- Base Styles for Navbar --- */
#navbar {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
  padding: 20px 0;
  transition: var(--transition);
  /* Use the theme-aware navbar background variable */
  background: var(--navbar-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  /* Use theme variable for border, defaulting to a subtle dark one */
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Adjust border for light theme */
html[data-theme='light'] #navbar {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

#navbar.scrolled {
  padding: 15px 0;
  /* Slightly more opaque on scroll */
  background: linear-gradient(rgba(10, 25, 47, 0.95), rgba(10, 25, 47, 0.95)), var(--navbar-bg);
  /* Fallback for browsers not supporting backdrop-filter */
  background: var(--navbar-bg);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  box-shadow: 0 5px 20px rgba(2, 12, 27, 0.9);
}

/* Adjust scrolled state for light theme */
html[data-theme='light'] #navbar.scrolled {
  background: linear-gradient(rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.98)), var(--navbar-bg);
  background: var(--navbar-bg);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative; /* Needed for absolute positioning if needed */
}

.logo {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  /* Logo should use primary color for contrast */
  color: var(--primary);
  text-decoration: none;
  flex-shrink: 0;
  z-index: 1;
}

/* --- Navigation Links --- */
.nav-links {
  display: flex;
  list-style: none;
  gap: 30px;
  align-items: center;
  margin: 0;
  padding: 0;
  flex: 1;
  justify-content: flex-end;
}

/* *** KEY CHANGE: Link text color uses theme variable *** */
.nav-links a {
  /* Use the main text color defined in main.css for theme contrast */
  color: var(--text-main); /* This will be dark in light theme, light in dark theme */
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  position: relative;
  padding: 5px 0;
  transition: var(--transition);
  white-space: nowrap;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 1px;
  /* Underline should use primary color */
  background-color: var(--primary);
  transition: var(--transition);
}

.nav-links a:hover {
  /* Hover color should also use primary */
  color: var(--primary);
}

.nav-links a:hover::after {
  width: 100%;
}

/* --- Theme Toggle Button Styling (Inside Navbar) --- */
.theme-toggle-container {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.theme-toggle-btn {
  background: none;
  /* Border color should adapt to theme */
  border: 1px solid var(--text-secondary); /* Use muted text color for border */
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  /* Icon color should adapt */
  color: var(--text-main); /* Use main text color for icon */
  transition: var(--transition);
  flex-shrink: 0;
  margin-left: 15px;
}

.theme-toggle-btn:hover {
  /* Background on hover */
  background-color: rgba(255, 255, 255, 0.1);
  /* Border and icon color on hover */
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-2px);
}

/* Ensure theme button adapts border/icon color in light theme */
html[data-theme='light'] .theme-toggle-btn {
  border: 1px solid var(--text-secondary);
  color: var(--text-main);
}
html[data-theme='light'] .theme-toggle-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
  border-color: var(--primary);
  color: var(--primary);
}

.theme-toggle-btn:focus {
  outline: 2px dashed var(--primary);
  outline-offset: 2px;
}

/* --- Mobile Menu Toggle --- */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  /* Color should adapt */
  color: var(--text-main);
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  margin-left: 15px;
  z-index: 1;
}

/* --- Responsive Styles --- */
@media (max-width: 768px) {
  .menu-toggle {
    display: block;
  }

  .nav-links {
    position: fixed;
    top: 70px;
    left: 0;
    width: 100%;
    /* Use theme variable for mobile menu background */
    background: var(--bg-body); /* Should match body background */
    flex-direction: column;
    align-items: flex-start;
    padding: 20px 0;
    clip-path: polygon(0 0, 100% 0, 100% 0, 0 0);
    transition: var(--transition);
    gap: 20px;
    justify-content: flex-start;
  }

  .nav-links.active {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
  }

  .nav-links li {
    margin: 0;
    width: 100%;
    text-align: center;
  }

  .nav-container {
    flex-wrap: nowrap;
    padding: 0 15px;
  }

  .menu-toggle {
     margin-left: auto;
  }

  /* Styles for the theme toggle INSIDE the mobile menu */
  .theme-toggle-container {
    margin: 0;
    padding-top: 10px;
    width: 100%;
    justify-content: center; /* Center the button in mobile menu */
  }

  .theme-toggle-btn {
    margin-left: 0;
  }
}

/* Ensure theme toggle is visible on larger screens */
@media (min-width: 769px) {
    .theme-toggle-container {
        display: flex !important;
    }
}
