/* ==========================================================================
   v2 styles: app shell, "Option G" (prototype e60a7f5). Loaded only when
   DP_NEW_STYLE is on.

   Overrides static/css/nav-option-c.css. The source of truth is the
   prototype's product/nav-option-c.css plus its `html[data-ui-concept]`
   rules for `.oc-*`:

   - Co-brand: Dataphoria owns the sidebar and the brand block above it
     (solid --oc-datha, white items, the Dataphoria logo) for every tenant, except
     the ones in NEW_STYLE_BRANDED_SIDEBAR, which keep their --bs-primary there.
     The tenant's --bs-primary stays on everything else: sub-bar tabs, the
     switcher, Help, the impersonation pill, the account avatar and the page
     content, so a tenant theme (Uni.Fund, Papadopoulou, ...) still reads as
     itself outside the sidebar.
   - The top bar carries the brand block, the tenant lead (logo or name) and
     the investee switcher; the active section's tabs move to a 44px
     `.oc-subbar` under it (templates/nav/topbar.html).

   Selectors repeat the specificity of the rule they override plus `.dp-v2`,
   so they win without `!important`.
   ========================================================================== */

.dp-v2 body.oc-nav {
  --oc-datha: #009891;
  --oc-datha-deep: #007a74;
  /* What the sidebar and its brand block paint with: Dataphoria teal, or the
     tenant's primary for the listed tenants (`.oc-sidebar-tenant`, set from
     NEW_STYLE_BRANDED_SIDEBAR). */
  --oc-side-bg: var(--oc-datha);
  --oc-side-deep: var(--oc-datha-deep);
  --oc-subbar-h: 44px;
  --oc-chrome-h: calc(var(--oc-topbar-h) + var(--oc-subbar-h));
  --oc-chrome-border: color-mix(in srgb, var(--bs-primary) 14%, #dee2e6);
  --oc-divider: #dee2e6;
  /* Pages that offset fixed or sticky parts by the chrome height read it from
     here (static/css/reports/reports.css declares it on :root). */
  --reports-topbar-h: var(--oc-chrome-h);
  background-color: var(--dp-bg);
}

.dp-v2 body.oc-nav.oc-sidebar-tenant {
  --oc-side-bg: var(--bs-primary);
  --oc-side-deep: color-mix(in srgb, var(--bs-primary) 80%, black);
}

/* -------------------------------------------------------------- sidebar --- */

.dp-v2 .oc-sidebar {
  background-color: var(--oc-side-bg);
  color: #fff;
  border-right: 0;
}

.dp-v2 .oc-sidebar-nav {
  padding: 12px 0 8px;
}

.dp-v2 .oc-sidebar-foot {
  border-top-color: rgba(255, 255, 255, 0.2);
}

/* 46px items: 11px padding around a 24px line of 16px text. */
.dp-v2 .oc-section {
  gap: 12px;
  margin: 0 6px 4px;
  padding: 11px 14px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.92);
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
}

.dp-v2 .oc-section:hover {
  background-color: rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* Selected item: a translucent pill with a 4px accent bar on its left edge
   (round 5, the client's reference image). Hover stays the weaker fill. */
.dp-v2 .oc-section {
  position: relative;
}

.dp-v2 .oc-section.active {
  background-color: rgba(255, 255, 255, 0.22);
  color: #fff;
  font-weight: 500;
  box-shadow: none;
}

.dp-v2 .oc-section.active::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 4px;
  border-radius: 8px 0 0 8px;
  background-color: rgba(255, 255, 255, 0.55);
}

.dp-v2 .oc-section.disabled {
  color: rgba(255, 255, 255, 0.75);
}

.dp-v2 .oc-section-icon {
  width: 18px;
  height: 18px;
}

.dp-v2 .oc-sidebar .oc-lock {
  color: inherit;
  opacity: 0.85;
}

.dp-v2 .oc-sidebar :focus-visible {
  outline-color: #fff;
}

/* --------------------------------------------------------------- top bar --- */

/* Same canvas as the page, not a separate white slab; the hairline takes a
   touch of the tenant primary. */
.dp-v2 .oc-topbar {
  background-color: var(--dp-bg);
  border-bottom-color: var(--oc-chrome-border);
}

/* Brand block: the top of the teal column while the sidebar is open (white
   mark), the bar's own canvas in the rail state (colour mark). */
.dp-v2 body.oc-nav .oc-topbar-brand {
  background-color: var(--oc-side-bg);
  border-right-color: var(--oc-divider);
}

.dp-v2 body.oc-nav.oc-rail .oc-topbar-brand {
  background-color: transparent;
}

.dp-v2 body.oc-nav .oc-brand {
  color: #fff;
}

.dp-v2 body.oc-nav.oc-rail .oc-brand {
  color: var(--oc-side-deep);
}

.dp-v2 .oc-brand img {
  max-height: 32px;
}

.dp-v2 body.oc-nav .oc-topbar-brand .oc-burger {
  color: #fff;
}

/* No hover fill on the burger, as the prototype (focus keeps its outline). */
.dp-v2 body.oc-nav .oc-topbar-brand .oc-burger:hover {
  background-color: transparent;
}

.dp-v2 body.oc-nav.oc-rail .oc-topbar-brand .oc-burger {
  color: var(--oc-side-deep);
}

.dp-v2 body.oc-nav.oc-rail .oc-topbar-brand .oc-burger:hover {
  background-color: transparent;
}

.dp-v2 .oc-topbar :focus-visible {
  outline-color: var(--dp-ring);
}

.dp-v2 body.oc-nav .oc-topbar-brand :focus-visible {
  outline-color: #fff;
}

.dp-v2 body.oc-nav.oc-rail .oc-topbar-brand :focus-visible {
  outline-color: var(--oc-side-deep);
}

/* Burger and Help: the prototype's 36px round icon buttons. Help takes the
   tenant primary (teal for Dataphoria). */
.dp-v2 .oc-burger,
.dp-v2 .oc-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.dp-v2 .oc-icon-btn {
  color: var(--bs-primary);
}

.dp-v2 .oc-icon-btn:hover {
  background-color: rgba(0, 0, 0, 0.06);
  color: var(--bs-primary);
}

.dp-v2 .oc-burger > .dp-icon {
  width: 18px;
  height: 18px;
}

.dp-v2 .oc-icon-btn > .dp-icon {
  width: 16px;
  height: 16px;
}

/* ----------------------------------------------------------- tenant lead --- */

/* The tenant's logo, else its name, leading the bar right of the brand block. */
.dp-v2 .oc-tenant-lead {
  display: inline-flex;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 220px;
  margin-right: 4px;
  padding-right: 12px;
  border-right: 1px solid var(--oc-divider);
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}

.dp-v2 .oc-tenant-lead img {
  display: block;
  width: auto;
  max-width: 180px;
  max-height: 30px;
  object-fit: contain;
}

.dp-v2 .oc-tenant-lead__wordmark {
  overflow: hidden;
  color: var(--dp-fg);
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------ investee switcher --- */

/* A compact control on the bar (it lived at the head of the sidebar before).
   The base sidebar and rail rules are all (0,2,1) or (0,3,1); these beat them. */
.dp-v2 .oc-topbar .oc-switcher {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 220px;
  margin-right: 4px;
  padding: 0 12px 0 0;
  border: 0;
  border-right: 1px solid var(--oc-divider);
}

.dp-v2 .oc-topbar .oc-switcher-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: auto;
  max-width: 100%;
  height: 40px;
  padding: 4px 10px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 8px;
  background-color: transparent;
  color: var(--dp-fg);
  text-align: left;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* The switcher tints only while its menu is open; hover changes nothing, as the prototype. */
.dp-v2 .oc-topbar .oc-switcher-btn:hover:not(.show) {
  background-color: transparent;
  border-color: transparent;
}

.dp-v2 .oc-topbar .oc-switcher-btn.show {
  background-color: color-mix(in srgb, var(--bs-primary) 6%, var(--dp-card));
  border-color: color-mix(in srgb, var(--bs-primary) 28%, var(--oc-divider));
  color: var(--dp-fg);
}

.dp-v2 .oc-topbar .oc-switcher-label {
  display: flex;
}

.dp-v2 body.oc-nav .oc-topbar .oc-switcher-chevron {
  display: inline-block;
}

.dp-v2 .oc-topbar .oc-switcher-icon,
.dp-v2 .oc-topbar .oc-switcher-chevron {
  color: var(--bs-primary);
}

.dp-v2 .oc-topbar .oc-switcher-icon {
  width: 16px;
  height: 16px;
}

.dp-v2 .oc-topbar .oc-switcher-chevron {
  width: 14px;
  height: 14px;
}

.dp-v2 .oc-topbar .oc-switcher-name {
  font-size: 0.82rem;
  font-weight: 700;
}

.dp-v2 .oc-topbar .oc-switcher-sub {
  font-size: 0.66rem;
  letter-spacing: 0.03em;
  color: var(--dp-muted-fg);
  opacity: 1;
}

.dp-v2 .oc-switcher-item {
  border-radius: var(--dp-radius-ctl);
}

.dp-v2 .oc-switcher-group {
  color: var(--dp-muted-fg);
}

/* --------------------------------------------------------------- sub-bar --- */

.dp-v2 .oc-subbar {
  position: fixed;
  top: var(--oc-topbar-h);
  left: var(--oc-width);
  right: 0;
  height: var(--oc-subbar-h);
  display: flex;
  align-items: stretch;
  padding: 0 16px;
  background-color: var(--dp-bg);
  border-bottom: 1px solid var(--oc-chrome-border);
  z-index: 1040;
  transition: left 0.25s ease;
}

.dp-v2 .oc-subbar .oc-tabs {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 2px;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.dp-v2 .oc-subbar .oc-tab {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  gap: 6px;
  padding: 0 12px;
  border-radius: 0;
  color: var(--dp-muted-fg);
  font-size: 12px;
  font-weight: 600;
}

/* Hover, as the prototype: a primary tint behind the tab, the label keeps its colour
   (grey, or black on the active tab). */
.dp-v2 .oc-subbar .oc-tab:hover,
.dp-v2 .oc-subbar .oc-tab.disabled.oc-upgrade:hover {
  background-color: rgba(var(--bs-primary-rgb), 0.08);
  color: var(--dp-muted-fg);
}

.dp-v2 .oc-subbar .oc-tab.active:hover {
  color: var(--dp-fg);
}

/* The underline is the tenant primary: teal for Dataphoria. */
.dp-v2 .oc-subbar .oc-tab.active {
  color: var(--dp-fg);
  box-shadow: inset 0 -2px 0 var(--bs-primary);
}

.dp-v2 .oc-subbar .oc-tab.disabled {
  color: color-mix(in srgb, var(--dp-muted-fg) 70%, transparent);
}

.dp-v2 .oc-subbar .oc-tab > .dp-icon {
  width: 14px;
  height: 14px;
}

.dp-v2 .oc-subbar .oc-tab .oc-lock {
  color: var(--dp-muted-fg);
  opacity: 1;
}

.dp-v2 .oc-subbar .oc-tab-title {
  display: inline-flex;
  align-items: center;
  padding: 0 4px;
  color: var(--dp-fg);
  font-size: 0.9rem;
  font-weight: 600;
}

/* "More": a `.oc-tab` inside a dropdown wrapper, centred in the bar. */
.dp-v2 .oc-subbar .oc-more {
  display: flex;
  align-items: center;
  flex: none;
}

.dp-v2 .oc-subbar .oc-more[hidden] {
  display: none;
}

.dp-v2 .oc-subbar .oc-more .oc-tab {
  align-self: center;
  padding: 6px 10px;
}

.dp-v2 .oc-subbar :focus-visible {
  outline: 2px solid var(--dp-ring);
  outline-offset: -2px;
}

/* Content starts under both bars, with the prototype's 15px page gutter (its
   content-wrapper 116px 0 0 + dp-box-container 0 15px 15px). The gutter sits on the
   wrapper, not the container, so pages that swap the container (dx-page,
   dp-plain-container, esg-report-builder), the flash alert and the footer keep it. */
.dp-v2 body.oc-nav .content-wrapper {
  padding: calc(var(--oc-chrome-h) + 1rem) 15px 0;
}

.dp-v2 body.oc-nav .dp-box-container {
  padding: 0 0 15px;
}

/* Sticky parts that offset themselves by the top bar alone. */
.dp-v2 body.oc-nav .branding-sticky {
  top: calc(var(--oc-chrome-h) + 12px);
  max-height: calc(100vh - var(--oc-chrome-h) - 24px);
}

/* Onboarding hides the chrome (static/css/v2/onboarding.css); the sub-bar is
   new, so hide it with the rest. */
.dp-v2 body.oc-nav:has(.onboarding-shell) .oc-subbar {
  display: none;
}

/* ------------------------------------------- impersonation pill & avatars --- */

/* The prototype's pill: 36px label row inside 5px padding, tenant primary on
   a 12% tint. The "View as…" starter takes the same height. */
.dp-v2 .oc-imp-pill {
  gap: 8px;
  padding: 5px 6px 5px 12px;
  border: 0;
  background-color: rgba(var(--bs-primary-rgb), 0.12);
  color: var(--bs-primary);
  font-size: 0.85rem;
  font-weight: 500;
}

.dp-v2 .oc-imp-pill-btn {
  min-height: 36px;
}

.dp-v2 .oc-imp-start {
  min-height: 46px;
  padding: 5px 14px;
}

.dp-v2 .oc-imp-start:hover {
  background-color: rgba(var(--bs-primary-rgb), 0.2);
}

.dp-v2 .oc-imp-pill .dp-icon {
  width: 14px;
  height: 14px;
}

.dp-v2 .oc-pill-x {
  width: 24px;
  height: 24px;
}

.dp-v2 .oc-pill-x:hover {
  background-color: rgba(var(--bs-primary-rgb), 0.2);
}

.dp-v2 .oc-recent-item {
  border-radius: var(--dp-radius-ctl);
  font-size: var(--dp-font-size);
  color: var(--dp-fg);
}

.dp-v2 .oc-recent-item:hover:not(:disabled),
.dp-v2 .oc-recent-item:focus-visible {
  background-color: var(--dp-muted);
}

.dp-v2 .oc-recent-item > .dp-icon {
  flex: none;
  margin-top: 2px;
  color: var(--dp-muted-fg);
}

.dp-v2 .oc-recent-user,
.dp-v2 .oc-menu-label,
.dp-v2 .oc-menu-sub {
  color: var(--dp-muted-fg);
}

.dp-v2 .oc-menu-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* F14: the account avatar is a rounded square filled with the tenant colour.
   White text, switched to black for a light tenant primary where relative
   colour syntax is supported (older browsers keep the white). */
.dp-v2 .oc-avatar {
  font-size: 12px;
  font-weight: 600;
}

.dp-v2 .oc-avatar-main {
  width: 36px;
  height: 36px;
  border-radius: var(--dp-radius);
  background-color: var(--bs-primary);
  color: #fff;
  color: oklch(from var(--bs-primary) clamp(0, (0.7 - l) * 1000, 1) 0 0);
}

/* No hover ring on the avatar, as the prototype. */
.dp-v2 .oc-avatar-main:hover {
  box-shadow: none;
}

.dp-v2 .oc-avatar-imp {
  border-radius: var(--dp-radius);
  background-color: var(--dp-card);
  color: var(--bs-primary);
  border-color: var(--bs-primary);
}

.dp-v2 .oc-badge-eye {
  border-color: var(--dp-card);
  background-color: var(--bs-primary);
  color: #fff;
}

.dp-v2 .oc-badge-eye > .dp-icon {
  width: 9px;
  height: 9px;
}

.dp-v2 .oc-investee-logo img {
  max-height: 24px;
}

/* ------------------------------------------------------------- dropdowns --- */

/* nav-option-c.css restates Bootstrap's dropdown under `body.oc-nav` at
   (0,2,1), so the component Sass cannot reach these menus; restyle them here
   to the shadcn menu: 6px radius, hairline border, shadow-md, 12.5px items. */
.dp-v2 body.oc-nav .dropdown-menu {
  padding: 4px;
  font-size: var(--dp-font-size);
  color: var(--dp-fg);
  background-color: var(--dp-card);
  border: 1px solid var(--dp-border);
  border-radius: var(--dp-radius);
  box-shadow: var(--dp-shadow-md);
}

.dp-v2 body.oc-nav .dropdown-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  border-radius: var(--dp-radius-ctl);
  color: var(--dp-fg);
}

.dp-v2 body.oc-nav .dropdown-item:hover,
.dp-v2 body.oc-nav .dropdown-item:focus {
  color: var(--dp-fg);
  background-color: var(--dp-muted);
}

.dp-v2 body.oc-nav .dropdown-item.active {
  color: var(--dp-accent-fg);
  background-color: var(--dp-accent);
  font-weight: 500;
}

.dp-v2 body.oc-nav .dropdown-item.disabled {
  color: var(--dp-muted-fg);
}

.dp-v2 body.oc-nav .dropdown-item > .dp-icon {
  flex: none;
  color: var(--dp-muted-fg);
}

.dp-v2 body.oc-nav .dropdown-divider {
  margin: 4px -4px;
  border-top-color: var(--dp-border);
}

.dp-v2 body.oc-nav .dropdown-header {
  font-size: 11px;
  color: var(--dp-muted-fg);
}

.dp-v2 .oc-menu-head {
  padding: 6px 8px 2px;
}

.dp-v2 .oc-menu-name {
  font-weight: 600;
}

.dp-v2 .oc-menu-danger,
.dp-v2 body.oc-nav .dropdown-item.oc-menu-danger,
.dp-v2 body.oc-nav .dropdown-item.oc-menu-danger:hover,
.dp-v2 body.oc-nav .dropdown-item.oc-menu-danger:focus {
  color: var(--dp-destructive);
}

.dp-v2 body.oc-nav .dropdown-item.oc-menu-danger:hover,
.dp-v2 body.oc-nav .dropdown-item.oc-menu-danger:focus {
  background-color: color-mix(in srgb, var(--dp-destructive) 8%, transparent);
}

.dp-v2 body.oc-nav .dropdown-item.oc-menu-danger > .dp-icon {
  color: inherit;
}

/* ------------------------------------------------------------ responsive --- */

/* Below 900px the sidebar is the 64px teal rail (nav-option-c.css) and the
   sub-bar starts at its edge. The brand block shrinks to burger + mark but
   stays teal with the white mark, as in the prototype, capping the rail.
   The burger opens the full sidebar as a sheet over the content
   (`body.oc-sheet-open`, static/js/nav-topbar.js under `.dp-v2` only) with a
   40% backdrop. The top bar's left group shrinks (tenant lead, switcher)
   before anything can run under the right-hand controls. */
@media (max-width: 900px) {
  .dp-v2 body.oc-nav .oc-topbar-brand,
  .dp-v2 body.oc-nav.oc-rail .oc-topbar-brand {
    padding: 0 8px 0 12px;
    margin-left: -16px;
    background-color: var(--oc-side-bg);
  }

  .dp-v2 body.oc-nav .oc-brand,
  .dp-v2 body.oc-nav.oc-rail .oc-brand {
    color: #fff;
  }

  .dp-v2 body.oc-nav .oc-brand-open,
  .dp-v2 body.oc-nav.oc-rail .oc-topbar-brand .oc-brand-open {
    display: flex;
  }

  .dp-v2 body.oc-nav .oc-brand-rail,
  .dp-v2 body.oc-nav.oc-rail .oc-topbar-brand .oc-brand-rail {
    display: none;
  }

  .dp-v2 body.oc-nav .oc-topbar-brand .oc-burger,
  .dp-v2 body.oc-nav.oc-rail .oc-topbar-brand .oc-burger {
    color: #fff;
  }

  .dp-v2 body.oc-nav .oc-topbar-brand .oc-burger:hover,
  .dp-v2 body.oc-nav.oc-rail .oc-topbar-brand .oc-burger:hover {
    background-color: transparent;
  }

  .dp-v2 body.oc-nav .oc-topbar-brand :focus-visible,
  .dp-v2 body.oc-nav.oc-rail .oc-topbar-brand :focus-visible {
    outline-color: #fff;
  }

  .dp-v2 body.oc-nav .oc-tenant-lead {
    max-width: 140px;
  }

  .dp-v2 body.oc-nav .oc-topbar .oc-switcher {
    max-width: 160px;
    padding-right: 8px;
  }

  .dp-v2 body.oc-nav .oc-topbar .oc-switcher-btn {
    height: 36px;
    padding: 3px 8px;
  }

  .dp-v2 .oc-imp-pill {
    max-width: 200px;
  }

  .dp-v2 .oc-subbar {
    padding: 0 8px;
  }

  .dp-v2 body.oc-nav.oc-sheet-open .oc-sidebar {
    width: var(--oc-sidebar-w);
    box-shadow: var(--dp-shadow-md);
  }

  .dp-v2 body.oc-nav.oc-sheet-open::after {
    content: "";
    position: fixed;
    inset: var(--oc-topbar-h) 0 0 0;
    z-index: 1040;
    background-color: color-mix(in srgb, var(--dp-fg) 40%, transparent);
  }

  .dp-v2 body.oc-nav.oc-sheet-open .oc-section {
    justify-content: flex-start;
    gap: 12px;
    padding: 11px 14px;
  }

  .dp-v2 body.oc-nav.oc-sheet-open .oc-section-label {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: hidden;
    clip-path: none;
  }

  .dp-v2 body.oc-nav.oc-sheet-open .oc-section .oc-lock {
    display: inline;
  }
}

/* Phones: the switcher keeps its icon and chevron, the tenant lead and the
   pill's label give way, so the account controls never leave the bar. */
@media (max-width: 600px) {
  .dp-v2 body.oc-nav .oc-tenant-lead {
    display: none;
  }

  .dp-v2 body.oc-nav .oc-topbar .oc-switcher-label {
    display: none;
  }

  .dp-v2 .oc-imp-pill .oc-pill-text {
    display: none;
  }

  .dp-v2 body.oc-nav .oc-brand {
    max-width: 96px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dp-v2 .oc-subbar {
    transition-duration: 0.01ms;
  }
}
