/* =============================================
   DATA PARTNER — Sub-Navbar (Second Fixed Navbar)
   Glassmorphism + Liquid Glass Popups
   ============================================= */

/* ===== SUB-NAVBAR CONTAINER ===== */
.sub-navbar {
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  right: 0;
  height: var(--sub-navbar-height, 52px);
  z-index: 990;
  display: none; /* Hidden for guests, shown after login */
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sub-navbar.visible {
  display: flex;
}

.sub-navbar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg-sub-navbar);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 2px 12px var(--glass-shadow);
  transition: all 0.4s ease;
}

/* Liquid glass shimmer on sub-navbar */
.sub-navbar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-border-hover), transparent);
  opacity: 0.5;
}

/* ===== SUB-NAVBAR INNER ===== */
.sub-navbar-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 0 var(--space-lg);
  gap: 4px;
  overflow: visible;
  justify-content: flex-start;
}

.sub-navbar-inner::-webkit-scrollbar {
  display: none;
}

/* ===== GROUP BUTTON ===== */
.sub-nav-group {
  position: relative;
  flex-shrink: 0;
}

.sub-nav-group-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

/* Ripple container for click effect */
.sub-nav-group-btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: var(--accent-primary);
  opacity: 0.15;
  transform: translate(-50%, -50%) scale(0);
  animation: glassRipple 0.6s ease-out;
  pointer-events: none;
}

.sub-nav-group-btn:hover {
  color: var(--text-accent);
  background: var(--glass-bg);
}

.sub-nav-group-btn .group-icon {
  font-size: 1rem;
  line-height: 1;
}

.sub-nav-group-btn .group-arrow {
  width: 12px;
  height: 12px;
  transition: transform 0.3s ease;
  opacity: 0.5;
}

.sub-nav-group.open .sub-nav-group-btn .group-arrow {
  transform: rotate(180deg);
}

/* Active group */
.sub-nav-group.active > .sub-nav-group-btn {
  color: var(--text-accent);
  background: var(--glass-bg);
}

/* Active indicator line */
.sub-nav-group.active > .sub-nav-group-btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--accent-primary);
  border-radius: 1px;
  box-shadow: 0 0 8px var(--accent-primary);
  animation: pulseGlow 2s ease-in-out infinite;
}

/* ===== POPUP DROPDOWN ===== */
.sub-nav-popup {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 200px;
  padding: 8px;
  border-radius: var(--radius-md);
  background: var(--dropdown-bg);
  backdrop-filter: blur(30px) saturate(200%);
  -webkit-backdrop-filter: blur(30px) saturate(200%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--dropdown-shadow);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  transform: translateX(-50%) translateY(-4px) scale(0.97);
  z-index: 1000;
}

/* Popup arrow */
.sub-nav-popup::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--dropdown-bg);
  border-left: 1px solid var(--glass-border);
  border-top: 1px solid var(--glass-border);
}

/* Liquid glass shimmer on popup */
.sub-nav-popup::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-border-hover), transparent);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

/* Open state */
.sub-nav-group.open .sub-nav-popup {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0) scale(1);
  animation: dropdownSlideIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== POPUP ITEMS ===== */
.sub-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.sub-nav-item:hover {
  color: var(--text-accent);
  background: var(--glass-bg);
}

/* Active item */
.sub-nav-item.active {
  color: var(--text-accent);
  background: var(--glass-bg-active);
  font-weight: 600;
}

.sub-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--accent-primary);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px var(--accent-primary);
}

.sub-nav-item .item-icon {
  font-size: 0.9rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* ===== SINGLE ITEMS (no dropdown) ===== */
.sub-nav-single {
  flex-shrink: 0;
}

.sub-nav-single-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.sub-nav-single-btn:hover {
  color: var(--text-accent);
  background: var(--glass-bg);
}

.sub-nav-single.active .sub-nav-single-btn {
  color: var(--text-accent);
  background: var(--glass-bg);
}

.sub-nav-single.active .sub-nav-single-btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--accent-primary);
  border-radius: 1px;
  box-shadow: 0 0 8px var(--accent-primary);
}

/* ===== CONTENT OFFSET WHEN SUB-NAVBAR VISIBLE ===== */
.main-content.with-sub-navbar {
  margin-top: calc(var(--navbar-height) + var(--sub-navbar-height, 52px));
}

/* ===== THEME SELECTOR IN SUB-NAVBAR ===== */
.sub-nav-theme-group {
  margin-left: auto;
  flex-shrink: 0;
}

.theme-selector-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 4px;
}

.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  background: none;
  font-family: var(--font-body);
}

.theme-option:hover {
  background: var(--glass-bg);
}

.theme-option.active {
  border-color: var(--accent-primary);
  background: var(--glass-bg-active);
}

.theme-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--glass-border);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.theme-swatch::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 50%;
  height: 100%;
}

.theme-option-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 500;
}

.theme-option.active .theme-option-label {
  color: var(--text-accent);
}

/* Specific swatches */
.theme-swatch[data-theme="light"] { background: #ffffff; border-color: #e2e8f0; }
.theme-swatch[data-theme="light"]::after { background: #0891b2; }

.theme-swatch[data-theme="dark"] { background: #0a0e27; }
.theme-swatch[data-theme="dark"]::after { background: #00f5ff; }

.theme-swatch[data-theme="ocean"] { background: #0c1e3a; }
.theme-swatch[data-theme="ocean"]::after { background: #06b6d4; }

.theme-swatch[data-theme="sunset"] { background: #271008; }
.theme-swatch[data-theme="sunset"]::after { background: #f97316; }

.theme-swatch[data-theme="forest"] { background: #0a2712; }
.theme-swatch[data-theme="forest"]::after { background: #10b981; }

.theme-swatch[data-theme="royal"] { background: #1a0a2a; }
.theme-swatch[data-theme="royal"]::after { background: #eab308; }

.theme-swatch[data-theme="rose"] { background: #fff1f3; border-color: #fecdd3; }
.theme-swatch[data-theme="rose"]::after { background: #ec4899; }

.theme-swatch[data-theme="midnight"] { background: #000000; }
.theme-swatch[data-theme="midnight"]::after { background: #3b82f6; }

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
  .sub-navbar {
    --sub-navbar-height: 48px;
  }

  .sub-navbar-inner {
    padding: 0 var(--space-sm);
    gap: 1px;
  }

  .sub-nav-group-btn,
  .sub-nav-single-btn {
    padding: 6px 10px;
    font-size: 0.78rem;
  }

  .sub-nav-group-btn .group-label {
    display: none;
  }

  .sub-nav-group-btn .group-icon {
    font-size: 1.1rem;
  }

  .sub-nav-group-btn .group-arrow {
    display: none;
  }

  .sub-nav-popup {
    position: fixed;
    top: calc(var(--navbar-height) + var(--sub-navbar-height, 48px));
    left: 8px;
    right: 8px;
    transform: none;
    max-width: calc(100vw - 16px);
  }

  .sub-nav-popup::before {
    display: none;
  }

  .sub-nav-group.open .sub-nav-popup {
    transform: translateY(0);
  }

  /* Theme group also icon-only on mobile */
  .sub-nav-theme-group .group-label {
    display: none;
  }

  .theme-selector-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .theme-swatch {
    width: 24px;
    height: 24px;
  }
}

/* ===== POPUP BACKDROP (mobile) ===== */
.sub-nav-backdrop {
  position: fixed;
  inset: 0;
  top: calc(var(--navbar-height) + var(--sub-navbar-height, 52px));
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
  z-index: 989;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
}

.sub-nav-backdrop.visible {
  opacity: 1;
  visibility: visible;
}
