/*
 * Kwalee BI — Application shell & navigation styles
 *
 * Covers: top navbar, sub-tabs, user menu dropdown, hamburger / mobile menu,
 * 404 page, and home placeholder.
 *
 * Responsive breakpoint: 768 px (mobile ↔ desktop).
 * All colour references go through theme.css semantic tokens.
 */

/* ================================================================== */
/* TOP NAVIGATION BAR                                                 */
/* ================================================================== */
.shell-navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  height: var(--nav-height);
  padding: 0 var(--spacing-lg);
  background: var(--bg-navbar, var(--bg-secondary));
  border-bottom: 1px solid var(--border-color);
  gap: var(--spacing-md);
}

/* ---- Logo -------------------------------------------------------- */
.shell-nav-logo {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  text-decoration: none;
  flex-shrink: 0;
}

.shell-nav-logo-mark {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.shell-nav-logo-text {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
}

.shell-nav-logo-accent {
  color: var(--accent);
}

/* ---- Primary nav items ------------------------------------------ */
.shell-nav-items {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  height: 100%;
}

.shell-nav-item {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 var(--spacing-md);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition:
    color 0.15s ease,
    border-color 0.15s ease;
  white-space: nowrap;
}

.shell-nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* Active state — yellow accent (per AC) */
.shell-nav-items.active-dashboards [data-section="dashboards"],
.shell-nav-items.active-explore [data-section="explore"],
.shell-nav-items.active-reports [data-section="reports"],
.shell-nav-items.active-admin [data-section="admin"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---- Spacer ------------------------------------------------------ */
.shell-nav-spacer {
  flex: 1;
}

/* ================================================================== */
/* USER MENU                                                          */
/* ================================================================== */
.shell-user-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.shell-user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-color);
  background: var(--bg-surface);
  cursor: pointer;
  transition: border-color 0.15s ease;
  padding: 0;
}

.shell-user-avatar:hover {
  border-color: var(--accent);
}

.shell-user-avatar-initial {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1;
}

/* ---- Dropdown ---------------------------------------------------- */
.shell-user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--spacing-sm) 0;
  z-index: 1010;
  display: none;
}

.shell-user-dropdown.shell-user-dropdown--open {
  display: block;
}

/* ---- Overlay (click-away dismiss) -------------------------------- */
.shell-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 1005;
  display: none;
}

.shell-menu-overlay.shell-menu-overlay--open {
  display: block;
}

/* ---- Profile section --------------------------------------------- */
.shell-user-profile {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md) var(--spacing-lg);
}

.shell-user-dropdown-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--accent-text);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.shell-user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.shell-user-email {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.shell-user-role {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  margin-top: var(--spacing-xs);
}

.shell-user-role-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.shell-user-role-value {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
}

/* ---- Dropdown divider -------------------------------------------- */
.shell-dropdown-divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--spacing-xs) 0;
}

/* ---- Theme toggle (segmented control) ---------------------------- */
.shell-theme-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-sm) var(--spacing-lg);
}

.shell-theme-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.shell-theme-toggle {
  display: flex !important;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 0;
}

/* Hide the native radio inputs */
.shell-theme-toggle .shell-theme-input {
  display: none !important;
}

.shell-theme-toggle .shell-theme-segment {
  display: flex;
  align-items: center;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
  white-space: nowrap;
  user-select: none;
}

.shell-theme-toggle .shell-theme-segment:hover {
  color: var(--text-primary);
}

/* Active segment — checked radio sibling label */
.shell-theme-toggle input:checked + .shell-theme-segment {
  background: var(--accent);
  color: var(--accent-text);
}

/* ---- Dropdown items ---------------------------------------------- */
.shell-dropdown-item {
  display: block;
  padding: var(--spacing-sm) var(--spacing-lg);
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition:
    background 0.1s ease,
    color 0.1s ease;
}

.shell-dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.shell-dropdown-signout {
  color: var(--color-error);
}

.shell-dropdown-signout:hover {
  background: color-mix(in srgb, var(--color-error) 10%, transparent);
  color: var(--color-error);
}

/* ================================================================== */
/* HAMBURGER BUTTON (mobile)                                          */
/* ================================================================== */
.shell-hamburger {
  display: none; /* Hidden on desktop */
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: none;
  border: none;
  cursor: pointer;
}

.shell-hamburger-line {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

/* Animated X when open */
.shell-hamburger.shell-hamburger--open .shell-hamburger-line:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.shell-hamburger.shell-hamburger--open .shell-hamburger-line:nth-child(2) {
  opacity: 0;
}
.shell-hamburger.shell-hamburger--open .shell-hamburger-line:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ================================================================== */
/* MOBILE MENU                                                        */
/* ================================================================== */
.shell-mobile-menu {
  display: none;
}

.shell-mobile-menu.shell-mobile-menu--open {
  display: block;
}

.shell-mobile-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--overlay-bg);
}

.shell-mobile-menu-content {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: var(--bg-secondary);
  padding: var(--spacing-lg) 0;
  overflow-y: auto;
}

.shell-mobile-nav-item {
  display: block;
  padding: var(--spacing-md) var(--spacing-xl);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition:
    background 0.1s ease,
    color 0.1s ease;
}

.shell-mobile-nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.shell-mobile-signout {
  color: var(--color-error);
}

/* ================================================================== */
/* SUB-NAVIGATION TABS                                                */
/* ================================================================== */
.shell-sub-tabs {
  /* position: fixed; */
  margin-top: var(--nav-height);
  display: flex;
  align-items: stretch;
  height: 40px;
  padding: 0 var(--spacing-lg);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  overflow: visible;
  gap: 0;
}

.shell-sub-tabs:empty {
  display: none;
}

.shell-sub-tabs::-webkit-scrollbar {
  height: 3px;
}

.shell-sub-tabs::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

.shell-sub-tabs::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 2px;
}

.shell-sub-tab {
  display: flex;
  align-items: center;
  padding: 0 var(--spacing-md);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition:
    color 0.15s ease,
    border-color 0.15s ease;
}

.shell-sub-tab:hover {
  color: var(--text-primary);
}

.shell-sub-tab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Parent tab with flyout children */
.shell-sub-tab--parent {
  position: relative;
  display: flex;
  align-items: stretch;
  border-bottom: 2px solid transparent;
}

.shell-sub-tab--parent.shell-sub-tab--active {
  border-bottom-color: var(--accent);
}

.shell-sub-tab__label {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 var(--spacing-md);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  cursor: default;
  white-space: nowrap;
  transition: color 0.15s ease;
}

a.shell-sub-tab__label {
  cursor: pointer;
}

.shell-sub-tab--parent:hover .shell-sub-tab__label,
.shell-sub-tab--parent.shell-sub-tab--active .shell-sub-tab__label {
  color: var(--text-primary);
}

.shell-sub-tab__caret {
  font-size: 0.6rem;
  opacity: 0.6;
  transition: transform 0.15s ease;
}

.shell-sub-tab--parent:hover .shell-sub-tab__caret {
  transform: rotate(180deg);
}

/* Flyout dropdown */
.shell-sub-tab-flyout {
  display: none;
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  min-width: 180px;
  padding: var(--spacing-xs) 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: var(--shadow-md);
  z-index: 1000;
}

.shell-sub-tab--parent:hover .shell-sub-tab-flyout,
.shell-sub-tab--parent:focus-within .shell-sub-tab-flyout {
  display: block;
}

.shell-sub-tab-flyout__item {
  display: block;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition:
    color 0.15s ease,
    background 0.15s ease;
}

.shell-sub-tab-flyout__item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.shell-sub-tab-flyout__item--active {
  color: var(--accent);
}

/* ================================================================== */
/* MAIN CONTENT AREA                                                  */
/* ================================================================== */
.shell-content {
  min-height: 100vh;
  /* padding-top: 40px; navbar 56px + sub-tabs 40px */
}

.shell-content--with-nav {
  /* padding-top: 40px; navbar 56 + sub-tabs 40 */
}

.shell-content--with-sub-tabs {
  /* padding-top: 40px; navbar 56 + sub-tabs 40 */
}

/* ================================================================== */
/* 404 PAGE                                                           */
/* ================================================================== */
.not-found-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 40px);
  padding: var(--spacing-2xl);
}

.not-found-content {
  text-align: center;
  max-width: 480px;
}

.not-found-code {
  font-family: var(--font-heading);
  font-size: 6rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: var(--spacing-md);
}

.not-found-message {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
}

.not-found-description {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: var(--spacing-xl);
  line-height: 1.5;
}

.not-found-link {
  display: inline-block;
  padding: var(--spacing-sm) var(--spacing-xl);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: background 0.15s ease;
}

.not-found-link:hover {
  background: var(--accent-hover);
}

/* ================================================================== */
/* HOME / PLACEHOLDER PAGE                                            */
/* ================================================================== */
.home-page {
  padding: var(--spacing-xl);
}

.home-heading {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
}

.home-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* ================================================================== */
/* RESPONSIVE — Mobile (<768px)                                       */
/* ================================================================== */
@media (max-width: 767px) {
  /* Hide desktop nav items, show hamburger */
  .shell-nav-items {
    display: none;
  }

  .shell-hamburger {
    display: flex;
  }

  /* Reorder: logo ... spacer ... user-avatar ... hamburger */
  .shell-navbar {
    padding: 0 var(--spacing-md);
  }

  .shell-sub-tabs {
    top: var(--nav-height);
    padding: 0 var(--spacing-md);
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }
}

@media (min-width: 768px) {
  /* Ensure mobile menu never shows on desktop */
  .shell-mobile-menu {
    display: none !important;
  }
}

/* ================================================================== */
/* MOCK-DATA BADGE                                                    */
/* ================================================================== */
.shell-mock-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-right: 12px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--color-warning) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-warning) 50%, transparent);
  color: var(--color-warning-text);
  font-family: var(--font-mono, monospace);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: default;
  user-select: none;
  white-space: nowrap;
  animation: mock-badge-pulse 3s ease-in-out infinite;
}

.shell-mock-badge__icon {
  font-size: 0.75rem;
}

@keyframes mock-badge-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.65;
  }
}
