/* OnlyFanOuts — Sidebar Navigation Component */

/* ── Body reset when sidebar is active ── */
body:has(.ofo-sidebar) {
  padding: 0;
}

/* Hide the old horizontal nav when sidebar is active */
body:has(.ofo-sidebar) > .ofo-nav {
  display: none;
}

/* ── Flex layout wrapper (sidebar + main) ── */
.ofo-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.ofo-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--gray-200);
  z-index: 200;
  display: flex;
  flex-direction: column;
  padding: 0;
}

/* ── Main content area ── */
.ofo-main {
  flex: 1;
  min-width: 0;
}

/* Brand block at top of sidebar */
.ofo-sidebar-brand {
  height: 65px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.ofo-sidebar-brand a {
  font-weight: 600;
  color: var(--gray-900);
  font-size: 16px;
  text-decoration: none;
  display: block;
  line-height: 1.1;
}
.ofo-sidebar-brand a:hover {
  text-decoration: none;
}

.ofo-sidebar-tagline {
  font-size: 9px;
  color: var(--gray-400);
  font-weight: 400;
  letter-spacing: 0.03em;
  margin-top: 2px;
  display: block;
}

/* Nav area inside sidebar */
.ofo-sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

/* ── Sections ── */
.ofo-sidebar-section {
  margin-bottom: 4px;
}

/* Section header (main item — clickable link + expand trigger) */
.ofo-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.ofo-sidebar-header:hover {
  background: var(--gray-50);
}

.ofo-sidebar-header a {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-400);
  text-decoration: none;
  flex: 1;
}

.ofo-sidebar-header a:hover {
  color: var(--gray-600);
  text-decoration: none;
}

/* Section is active (contains current page) */
.ofo-sidebar-section.active > .ofo-sidebar-header a {
  color: var(--blue-500);
}

/* Expand/collapse chevron */
.ofo-sidebar-chevron {
  font-size: 10px;
  color: var(--gray-400);
  transition: transform 0.2s;
  flex-shrink: 0;
  margin-left: 8px;
}

.ofo-sidebar-section.expanded > .ofo-sidebar-header .ofo-sidebar-chevron {
  transform: rotate(90deg);
}

/* ── Sub-items ── */
.ofo-sidebar-items {
  display: none;
  padding: 0 0 8px;
}

.ofo-sidebar-section.expanded > .ofo-sidebar-items {
  display: block;
}

.ofo-sidebar-item {
  display: block;
  padding: 7px 20px 7px 36px;
  font-size: 14px;
  color: var(--gray-600);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.ofo-sidebar-item:hover {
  background: var(--gray-50);
  color: var(--gray-900);
  text-decoration: none;
}

/* Active sub-item */
.ofo-sidebar-item.active {
  color: var(--blue-500);
  font-weight: 600;
  background: rgba(37, 99, 235, 0.04);
  border-left-color: var(--blue-500);
}

/* ── Top bar (slim, user menu only) ── */
.ofo-topbar {
  height: 65px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  gap: 16px;
}

/* ── Container adjustments for sidebar layout ── */
body:has(.ofo-sidebar) .container {
  border-radius: 0;
}

/* ── Env banner adjustment for sidebar ── */

body:has(.ofo-sidebar):has(.env-banner) .ofo-layout {
  padding-top: 26px;
}

/* ══════════════════════════════════════════════════════════════════════
   Mobile Tab Bar — hidden on desktop, replaces sidebar on mobile
   ══════════════════════════════════════════════════════════════════════ */

.ofo-tabbar,
.ofo-tabbar-backdrop,
.ofo-tabbar-popover {
  display: none;
}

/* ── Mobile breakpoint ── */
@media (max-width: 767px) {
  /* Make layout the positioning context for the brand overlay */
  .ofo-layout {
    position: relative;
  }

  /* Collapse sidebar to brand-only, overlaid on topbar area */
  .ofo-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: auto;
    border-right: none;
    background: transparent;
    z-index: 201;
    pointer-events: none;
  }

  .ofo-sidebar-brand {
    height: 48px;
    border-bottom: none;
    padding: 0 12px;
    pointer-events: auto;
  }

  .ofo-sidebar-nav {
    display: none;
  }

  body:has(.env-banner) .ofo-sidebar {
    top: 26px;
  }

  /* ── Tab bar ── */
  .ofo-tabbar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: #fff;
    border-top: 1px solid var(--gray-200);
    z-index: 500;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  /* Bottom padding so content isn't hidden behind tab bar */
  .ofo-main {
    padding-bottom: 72px;
  }

  /* ── Tab items (both <a> and <button>) ── */
  .ofo-tabbar-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    height: 100%;
    padding: 6px 0;
    background: none;
    border: none;
    color: var(--gray-400);
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
  }

  .ofo-tabbar-tab:hover,
  .ofo-tabbar-tab:focus {
    text-decoration: none;
    outline: none;
  }

  .ofo-tabbar-tab.active {
    color: var(--blue-500);
  }

  .ofo-tabbar-tab svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  .ofo-tabbar-label {
    font-size: 10px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  /* ── Backdrop ── */
  .ofo-tabbar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 499;
  }

  .ofo-tabbar-backdrop.open {
    display: block;
  }

  /* ── Popover (bottom sheet above tab bar) ── */
  .ofo-tabbar-popover {
    position: fixed;
    bottom: calc(56px + env(safe-area-inset-bottom, 0));
    left: 8px;
    right: 8px;
    background: #fff;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    z-index: 501;
    padding: 8px 0;
  }

  .ofo-tabbar-popover.open {
    display: block;
    animation: ofo-slide-up 0.2s ease-out;
  }

  @keyframes ofo-slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  .ofo-tabbar-popover-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-400);
    padding: 8px 16px 4px;
  }

  .ofo-tabbar-popover-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    font-size: 15px;
    color: var(--gray-700);
    text-decoration: none;
    min-height: 44px;
    transition: background 0.1s;
  }

  .ofo-tabbar-popover-item:hover {
    background: var(--gray-50);
    text-decoration: none;
  }

  .ofo-tabbar-popover-item.active {
    color: var(--blue-500);
    font-weight: 600;
  }

  /* ── Compact topbar on mobile ── */
  .ofo-topbar {
    height: 48px;
    padding: 0 12px;
  }

  .ofo-topbar .user-menu-email {
    display: none;
  }

  /* ── Landscape: compact icon-only tab bar ── */
  @media (orientation: landscape) {
    .ofo-tabbar {
      height: 44px;
    }

    .ofo-tabbar-label {
      display: none;
    }

    .ofo-main {
      padding-bottom: 60px;
    }

    .ofo-tabbar-popover {
      bottom: calc(44px + env(safe-area-inset-bottom, 0));
    }
  }
}
