/**
 * Unified Short & Collapsible Navigation Menu Styles
 * Astrology AI Suite
 */

/* Nav Links Container - Short Footprint */
.nav-links {
  position: relative;
  display: inline-flex !important;
  align-items: center;
  gap: 3px;
  background: var(--bg-subtle, #F3F4F6);
  padding: 3px 4px;
  border-radius: var(--radius-full, 9999px);
  border: 1px solid var(--border, #E5E7EB);
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: visible !important;
}

/* Individual Nav Button */
.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full, 9999px);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary, #4B5563);
  text-decoration: none;
  transition: all var(--transition, 150ms cubic-bezier(0.4, 0, 0.2, 1));
  border: 1px solid transparent;
  user-select: none;
  background: transparent;
  cursor: pointer;
  line-height: 1.4;
  box-sizing: border-box;
}

.nav-btn:hover {
  background: var(--bg-hover, rgba(0, 0, 0, 0.05));
  color: var(--text-main, #111827);
}

.nav-btn.active {
  background: var(--bg-card, #FFFFFF);
  border-color: var(--border-strong, #D1D5DB);
  color: var(--primary, #4F46E5);
  font-weight: 600;
  box-shadow: var(--shadow-sm, 0 1px 2px 0 rgba(0, 0, 0, 0.05));
}

.nav-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.nav-btn.active svg {
  color: var(--primary, #4F46E5);
}

/* Nav Collapse Toggle Button (↔) */
.nav-collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full, 9999px);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted, #9CA3AF);
  cursor: pointer;
  padding: 0;
  transition: all var(--transition, 150ms ease);
  flex-shrink: 0;
}

.nav-collapse-btn:hover {
  background: var(--bg-hover, rgba(0, 0, 0, 0.06));
  color: var(--text-main, #111827);
  border-color: var(--border, #E5E7EB);
}

.nav-collapse-btn svg {
  width: 13px;
  height: 13px;
  transition: transform 200ms ease;
}

/* Dropdown Trigger Button */
.nav-dropdown-trigger {
  position: relative;
  font-weight: 600;
}

.nav-dropdown-trigger .nav-tools-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--primary-light, #EEF2FF);
  color: var(--primary, #4F46E5);
  padding: 1px 5px;
  border-radius: var(--radius-full, 9999px);
  border: 1px solid var(--primary-border, #C7D2FE);
  line-height: 1.1;
  margin-left: 2px;
}

.nav-dropdown-trigger .nav-chevron {
  width: 12px;
  height: 12px;
  transition: transform 200ms ease;
  margin-left: 1px;
}

.nav-dropdown-trigger.open .nav-chevron {
  transform: rotate(180deg);
}

/* Collapsed State: Only show collapse button + tools dropdown trigger */
.nav-links.is-collapsed .nav-primary-link {
  display: none !important;
}

.nav-links.is-collapsed .nav-collapse-btn svg {
  transform: rotate(180deg);
}

/* ========================= Dropdown Popover (App Drawer) ========================= */
.nav-dropdown-anchor {
  position: relative;
  display: inline-flex;
  overflow: visible !important;
}

.nav-dropdown-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 99999 !important;
  background: var(--bg-card, #FFFFFF);
  border: 1px solid var(--border-strong, #D1D5DB);
  border-radius: 14px;
  box-shadow: var(--shadow-dropdown, 0 12px 28px -4px rgba(0,0,0,0.18), 0 6px 12px -4px rgba(0,0,0,0.08));
  width: 360px;
  max-width: 92vw;
  max-height: min(520px, calc(100vh - 80px));
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: navPopoverFade 150ms cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
}

.nav-dropdown-popover.open {
  display: flex !important;
}

@keyframes navPopoverFade {
  from {
    opacity: 0;
    transform: translateY(-5px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Popover Header */
.nav-popover-header {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border, #E5E7EB);
  background: var(--bg-subtle, #F9FAFB);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.nav-popover-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-popover-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary, #4B5563);
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-popover-count {
  font-size: 10.5px;
  background: var(--primary-light, #EEF2FF);
  color: var(--primary, #4F46E5);
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
  border: 1px solid var(--primary-border, #C7D2FE);
}

.nav-popover-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.nav-popover-search-icon {
  position: absolute;
  left: 8px;
  width: 13px;
  height: 13px;
  color: var(--text-muted, #9CA3AF);
  pointer-events: none;
}

.nav-popover-search {
  width: 100%;
  padding: 5px 8px 5px 26px;
  font-size: 12px;
  font-family: inherit;
  border: 1px solid var(--border, #E5E7EB);
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-card, #FFFFFF);
  color: var(--text-main, #111827);
  outline: none;
  transition: border-color var(--transition, 150ms ease);
  box-sizing: border-box;
}

.nav-popover-search:focus {
  border-color: var(--primary, #4F46E5);
}

/* Popover Scroll Area */
.nav-popover-scroll {
  padding: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.nav-popover-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-popover-cat-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted, #9CA3AF);
  padding: 4px 8px 2px;
}

/* Popover Item */
.nav-popover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm, 8px);
  text-decoration: none;
  color: var(--text-main, #111827);
  transition: all 120ms ease;
  border: 1px solid transparent;
}

.nav-popover-item:hover {
  background: var(--bg-hover, rgba(0, 0, 0, 0.05));
  border-color: var(--border, #E5E7EB);
}

.nav-popover-item.active {
  background: var(--primary-light, #EEF2FF);
  border-color: var(--primary-border, #C7D2FE);
}

.nav-popover-item-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--bg-subtle, #F3F4F6);
  border: 1px solid var(--border, #E5E7EB);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary, #4B5563);
}

.nav-popover-item.active .nav-popover-item-icon {
  background: var(--bg-card, #FFFFFF);
  color: var(--primary, #4F46E5);
  border-color: var(--primary-border, #C7D2FE);
}

.nav-popover-item-icon svg {
  width: 14px;
  height: 14px;
}

.nav-popover-item-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.nav-popover-item-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.nav-popover-item-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main, #111827);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-popover-item.active .nav-popover-item-name {
  color: var(--primary, #4F46E5);
}

.nav-popover-item-desc {
  font-size: 11px;
  color: var(--text-muted, #6B7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.nav-popover-item-tag {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--primary, #4F46E5);
  color: white;
  margin-left: auto;
  flex-shrink: 0;
}

.nav-popover-item.hidden-by-search {
  display: none !important;
}

/* ========================= Header Overflow & Collision Prevention ========================= */
#header, .app-header, header {
  overflow: visible !important;
  z-index: 1000 !important;
}

.header-left-group, .header-left {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  overflow: visible !important;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-right-group, .header-right {
  flex-shrink: 0 !important;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  overflow: visible !important;
}

#profile-chip {
  max-width: 240px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  flex-shrink: 1 !important;
}

#profile-chip-text {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  display: inline-block;
  max-width: 200px;
}

/* Responsive Auto-Collapse on screens below 880px */
@media (max-width: 880px) {
  .nav-links .nav-primary-link {
    display: none !important;
  }
}

/* Mobile Full App Drawer View */
@media (max-width: 640px) {
  .nav-dropdown-popover {
    position: fixed !important;
    top: 60px !important;
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    max-width: calc(100vw - 20px) !important;
    max-height: calc(100vh - 75px) !important;
    border-radius: 16px !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35) !important;
  }
}
