/* ===================================
   Topbar Navigation Styles
   =================================== */

/* Main Topbar Container */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px) saturate(1.2);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(26, 62, 113, 0.08);
  transition: all 0.3s ease;
}

.topbar-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 2rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

/* Brand/Logo */
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: white;
  font-weight: 600;
  font-size: 1.1rem;
}

.topbar-logo {
  height: 40px;
  width: auto;
}

.topbar-title {
  display: none;
}

/* Menu Toggle Button (Mobile) */
.topbar-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  align-items: center;
  justify-content: center;
}

.toggle-line {
  width: 24px;
  height: 2px;
  background-color: white;
  transition: all 0.3s ease;
  border-radius: 2px;
}

.topbar-toggle.active .toggle-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.topbar-toggle.active .toggle-line:nth-child(2) {
  opacity: 0;
}

.topbar-toggle.active .toggle-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Navigation Menu */
.topbar-menu {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Navigation Links */
.topbar-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background-color 0.2s;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  white-space: nowrap;
}

.topbar-link:hover {
  background-color: rgba(26, 62, 113, 0.1);
}

.topbar-link.active {
  background-color: rgba(26, 62, 113, 0.15);
  border-bottom: 3px solid var(--cpar-blue-700);
}

.topbar-link--admin {
  color: var(--cpar-gold);
}

.topbar-link--login {
  margin-left: auto;
  background-color: rgba(26, 62, 113, 0.1);
}

.topbar-link--login:hover {
  background-color: rgba(26, 62, 113, 0.2);
}

.link-icon {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.link-text {
  display: none;
}

/* Dropdown Styles */
.topbar-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}

/* Dropdown Trigger Button */
.dropdown-trigger {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  transition: background-color 0.2s;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.dropdown-trigger:hover {
  background-color: rgba(26, 62, 113, 0.1);
}

.dropdown-trigger:focus {
  outline: 2px solid var(--cpar-gold);
  outline-offset: 2px;
}

/* Dropdown Arrow Animation */
.dropdown-arrow {
  font-size: 0.75rem;
  transition: transform 0.2s;
  display: inline-block;
}

.dropdown-trigger[aria-expanded="true"] .dropdown-arrow {
  transform: rotate(180deg);
}

/* Dropdown Menu */
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 250px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  margin-top: 0.5rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: 100;
  pointer-events: none;
  padding: 0.5rem 0;
  border: 1px solid var(--border);
}

.dropdown-trigger[aria-expanded="true"] ~ .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* Dropdown Item */
.dropdown-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text);
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background-color 0.2s;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.dropdown-item:hover {
  background-color: var(--surface);
}

.dropdown-item.active {
  background-color: var(--surface);
  color: var(--cpar-blue-700);
  font-weight: 500;
}

.dropdown-item.dropdown-item--danger:hover {
  background-color: #fee;
  color: #c33;
}

.dropdown-item:focus {
  outline: 2px solid var(--cpar-gold);
  outline-offset: -2px;
}

/* Item Icon */
.item-icon {
  font-size: 1.1rem;
  min-width: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Item Text Container */
.item-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
}

/* Item Description */
.item-desc {
  font-size: 0.8rem;
  color: var(--muted);
  display: block;
}

/* Dropdown Divider */
.dropdown-divider {
  height: 1px;
  background-color: var(--border);
  margin: 0.5rem 0;
}

/* Admin Menu Styling */
.dropdown-menu--admin {
  min-width: 280px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .topbar-container {
    height: 60px;
    padding: 0 0.75rem;
  }

  .topbar-brand {
    gap: 0.5rem;
  }

  .topbar-logo {
    height: 32px;
  }

  .topbar-toggle {
    display: flex;
  }

  .topbar-menu {
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    max-height: calc(100vh - 70px);
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    align-items: flex-start;
    width: 100%;
    padding: 0;
    z-index: 99;
    border-bottom: 1px solid var(--border);
  }

  .topbar-menu.active {
    transform: translateX(0);
  }

  .topbar-link {
    width: 100%;
    padding: 0.75rem 1.25rem;
    border: none;
    border-left: 3px solid transparent;
    border-radius: 0;
  }

  .topbar-link.active {
    border-bottom: none;
    border-left: 3px solid white;
    background-color: rgba(255, 255, 255, 0.15);
  }

  .link-text {
    display: inline;
  }

  .topbar-dropdown {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
  }

  .dropdown-trigger {
    width: 100%;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-radius: 0;
    border-left: 3px solid transparent;
  }

  .dropdown-trigger:hover {
    background-color: rgba(255, 255, 255, 0.15);
  }

  .dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    background: rgba(26, 62, 113, 0.05);
    margin: 0;
    border-radius: 0;
    border: none;
    pointer-events: auto;
    display: none;
    padding: 0;
    z-index: 99;
    width: 100%;
  }

  .dropdown-trigger[aria-expanded="true"] ~ .dropdown-menu {
    display: block;
    padding: 0.5rem 0;
  }

  .dropdown-item {
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
  }

  .item-desc {
    display: none;
  }

  .topbar-link--login {
    margin-left: 0;
  }

  .topbar-logout-form {
    width: 100%;
  }

  .topbar-logout-form .dropdown-item {
    background: none;
    border: none;
    cursor: pointer;
  }
}

/* Desktop Menu Display */
@media (min-width: 769px) {
  .topbar-menu {
    gap: 0.5rem;
  }

  .link-icon {
    display: none;
  }

  .link-text {
    display: inline;
  }

  .topbar-link--login {
    margin-left: auto;
  }

  .topbar-toggle {
    display: none;
  }

  .topbar-title {
    display: inline;
  }

  .dropdown-trigger {
    width: auto;
    justify-content: flex-start;
  }
}
