/* Hide the webpack-dev-server runtime error overlay — single-spa app failures
   are handled by addErrorHandler in the shell and must not surface here. */
#webpack-dev-server-client-overlay { display: none !important; }

/* Layout */
body {
  background-color: #F4F6F9;
  color: #3B3B3B;
}

/* ── Shell trigger safe zone ──
   Apps should keep content clear of this corner.
   --shell-trigger-safe-width  : horizontal clearance from the left edge
   --shell-trigger-safe-height : vertical clearance from the top edge
   Sidebar pin state is handled separately via margin-left on #shell-main. */
:root {
  --shell-trigger-safe-width: 50px;
  --shell-trigger-safe-height: 50px;
}

/* ========================================
   Shell Navigation — Desktop (sidebar)
   ======================================== */
#shell-nav {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: 200px;
  background-color: var(--color-primary);
  padding: 72px 8px 40px 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
  z-index: var(--z-index-sticky);
  transform: translateX(-100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform var(--transition-duration-normal) ease,
              visibility 0s var(--transition-duration-normal);
}

/* Sidebar visible states */
#shell-nav.peeking,
#shell-nav.pinned {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
  transition: transform var(--transition-duration-normal) ease,
              visibility 0s 0s;
}

/* Header: logo */
#shell-nav__header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* Apps: middle section, fills vertical space */
#shell-nav__apps {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
  margin-top: 30px;
  overflow-y: auto;
  scrollbar-width: none;
}

#shell-nav__apps::-webkit-scrollbar {
  display: none;
}

/* Footer: settings + account */
#shell-nav__footer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 30px;
  margin-top: 30px;
}

/* Individual nav item */
.shell-nav__item {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 4px 9.5px;
  border-radius: var(--radius-md);
  transition: background-color 150ms ease;
}

#shell-nav .material-icons {
  color: var(--color-text-inverse);
  font-size: 25px;
  flex-shrink: 0;
}

/* Labels always visible — sidebar is full-width whenever shown */
.shell-nav__label {
  color: var(--color-text-inverse);
  font-family: var(--font-family-body);
  font-size: var(--font-size-sm);
  white-space: nowrap;
  display: inline;
}

/* Logo image */
#shell-nav__logo-img {
  width: 25px;
  height: 25px;
  flex-shrink: 0;
}

/* "More" button — hidden on desktop */
.shell-nav__item--more {
  display: none;
}

/* "More" sheet — hidden on desktop */
#shell-nav__more-sheet {
  display: none;
}

/* ── Hamburger trigger — fixed top-left corner ── */
#shell-nav__trigger {
  position: fixed;
  top: 0px;
  left: 0px;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-md);
  z-index: calc(var(--z-index-sticky) + 1);
  transition: background-color 150ms ease;
}

/* White icon on transparent background — apps must ensure dark content behind this corner */
#shell-nav__trigger .material-icons {
  font-size: 24px;
  color: var(--color-surface);
}

/* Account mini panel — desktop: right of sidebar */
#account-panel {
  position: fixed;
  left: 200px;
  background-color: var(--color-surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: none;
  transform: translateY(-50%);
  z-index: var(--z-index-dropdown);
}

#account-panel.open {
  display: block;
}

#shell-logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  width: 100%;
  background: none;
  border: none;
  color: var(--color-text-primary);
  cursor: pointer;
  white-space: nowrap;
}

#shell-logout-btn:hover {
  background-color: var(--color-background);
}

#shell-logout-btn .material-icons {
  font-size: 25px;
  color: var(--color-text-secondary);
}

/* Main content — no sidebar by default */
#shell-main {
  margin-left: 0;
  padding: 0;
  transition: margin-left var(--transition-duration-normal) ease;
}

/* Pinned sidebar pushes content */
#shell-nav.pinned ~ #shell-main {
  margin-left: 200px;
}

/* ========================================
   Shell Navigation — Mobile (bottom bar)
   ======================================== */
@media (max-width: 767px) {

  /* Transform sidebar into bottom bar */
  #shell-nav {
    top: auto;
    bottom: 0;
    left: 0;
    height: auto;
    width: 100%;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    padding: var(--spacing-2) 0;
    padding-bottom: calc(var(--spacing-2) + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 8px rgba(22, 0, 118, 0.10);
    transform: none;
    visibility: visible;
    pointer-events: auto;
    transition: none;
  }

  /* Disable peek/pin on mobile */
  #shell-nav.peeking,
  #shell-nav.pinned {
    width: 100%;
    padding-left: 0;
    padding-right: 0;
    align-items: center;
    transform: none;
    visibility: visible;
    pointer-events: auto;
    transition: none;
  }

  #shell-nav.pinned .shell-nav__label {
    display: block;
  }

  /* Flatten section wrappers so all items are direct flex children
     of #shell-nav — gives a true iOS tab bar layout */
  #shell-nav__header,
  #shell-nav__apps,
  #shell-nav__footer {
    display: contents;
  }

  /* Hide hamburger trigger on mobile — bottom bar takes over */
  #shell-nav__trigger,
  #shell-nav__settings {
    display: none !important;
  }

  /* Scale logo to match material icon size on mobile */
  #shell-nav__logo-img {
    width: 22px;
    height: 22px;
  }

  /* Nav items: stacked icon + tiny label (iOS tab bar style) */
  .shell-nav__item {
    flex-direction: column;
    gap: 2px;
    padding: var(--spacing-1) var(--spacing-3);
    min-width: 64px;
    align-items: center;
    justify-content: center;
  }

  /* Labels always visible on mobile (small text under icon) */
  .shell-nav__label {
    display: block;
    font-size: var(--font-size-xs);
    opacity: 0.7;
  }

  /* Active state */
  .shell-nav__item--active .shell-nav__label {
    opacity: 1;
  }

  .shell-nav__item--active .material-icons {
    color: var(--color-primary-light);
  }

  #shell-nav .material-icons {
    font-size: 22px;
  }

  /* "More" button — visible when JS adds --visible */
  .shell-nav__item--more.shell-nav__item--visible {
    display: flex;
  }

  /* Main content: no left margin, bottom padding for bar, reset header offset */
  #shell-main {
    margin-left: 0;
    padding-top: 0;
    padding-bottom: 72px;
  }

  #shell-nav.pinned ~ #shell-main {
    margin-left: 0;
  }

  /* Account panel — mobile: above bottom bar, centered.
     !important on top overrides any inline style set by desktop JS. */
  #account-panel {
    left: 50%;
    bottom: 72px;
    top: auto !important;
    transform: translateX(-50%);
    border-radius: var(--radius-lg);
  }

  #shell-nav.pinned ~ #account-panel {
    left: 50%;
  }

  /* "More" sheet — Apple-style bottom sheet */
  #shell-nav__more-sheet.open {
    position: fixed;
    bottom: 72px;
    left: var(--spacing-4);
    right: var(--spacing-4);
    background-color: var(--color-surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-6) var(--spacing-4);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-4);
    justify-items: center;
    z-index: var(--z-index-dropdown);
  }

  /* Items inside the "More" sheet */
  .shell-nav__more-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-1);
    padding: var(--spacing-3);
    cursor: pointer;
    border-radius: var(--radius-md);
  }

  .shell-nav__more-item:active {
    background-color: var(--color-surface-sunken);
  }

  .shell-nav__more-item .material-icons {
    font-size: 28px;
    color: var(--color-primary);
  }

  .shell-nav__more-item__label {
    font-family: var(--font-family-body);
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
  }
}

/* ── Error Pages ── */
.shell-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
  text-align: center;
}

/* Small navy patch behind the hamburger so the white icon is visible on error pages */
.shell-error::before {
  content: '';
  position: fixed;
  top: 10px;
  left: 10px;
  width: 30px;
  height: 30px;
  background-color: var(--color-primary);
  z-index: 200;
}

.shell-error__icon {
  font-size: 64px;
  color: var(--color-primary-light);
  margin-bottom: 24px;
  opacity: 0.7;
}

.shell-error__title {
  font-family: var(--font-family-heading);
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-3xl);
  color: var(--color-text-primary);
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.shell-error__message {
  font-family: var(--font-family-body);
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  max-width: 400px;
  line-height: 1.6;
  margin-bottom: 32px;
}

.shell-error__action {
  font-family: var(--font-family-body);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-inverse);
  background-color: var(--color-primary);
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 28px;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.shell-error__action:hover {
  background-color: var(--color-primary-hover);
}
