/* erp-tabs.css — internal browser-tab shell (iframe-based) */

/* A page loaded inside one of our own tab iframes must not show its own
   copy of the sidebar/topbar/tab-bar — the top-level document already has one. */
body.erp-in-frame #layout-wrapper > .vertical-menu,
body.erp-in-frame #page-topbar,
body.erp-in-frame .erp-tabs-bar,
body.erp-in-frame .erp-ctx-menu,
body.erp-in-frame #fchat-btn,
body.erp-in-frame #fchat-panel,
body.erp-in-frame .right-bar,
body.erp-in-frame .rightbar-overlay {
    display: none !important;
}

body.erp-in-frame .main-content {
    margin-left: 0 !important;
}

/* .page-content has padding-top:90px globally (see app.min.css) to clear
   the fixed 70px topbar. Inside a tab iframe the topbar is hidden (rule
   above), so that padding is now pure dead space above every single
   page's content — fix it here once for all pages, instead of per-page. */
body.erp-in-frame .page-content {
    padding-top: 15px !important;
}

/* The outer/top-level shell document's own $content (including its own
   footer) is always discarded/replaced by the tab iframes — it never
   becomes visible, and its footer would otherwise force the fixed-height
   flex layout below to overflow. Pages rendered *inside* a tab iframe
   (body has both .erp-tabbed and .erp-in-frame) keep their own footer,
   since that's real, visible, scrollable content. */
body.erp-tabbed:not(.erp-in-frame) .footer {
    display: none;
}

/* Tabbed shell: each tab's real scrolling happens *inside* its iframe (that
   page has its own document/scrollbar — normal, unmodified). Only the
   OUTER/top-level shell (erp-tabbed but NOT erp-in-frame) must not also be
   scrollable, or you get a confusing double scrollbar — its only real job
   is to hold the tab bar + fill the rest of the viewport with the active
   iframe. Pages loaded *inside* a tab iframe get both classes and are
   deliberately excluded from all of this, so they scroll completely
   normally, like any other page in the app. */
html.erp-tabbed:not(.erp-in-frame),
html.erp-tabbed:not(.erp-in-frame) body {
    height: 100%;
    overflow: hidden;
}

body.erp-tabbed:not(.erp-in-frame) .main-content {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

body.erp-tabbed:not(.erp-in-frame) .page-content {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 !important;
    overflow: hidden;
}

body.erp-tabbed:not(.erp-in-frame) .page-content > .container-fluid {
    height: 100%;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
}

.erp-tabs-bar {
    display: flex;
    align-items: stretch;
    background: var(--bs-body-bg, #fff);
    border-bottom: 1px solid var(--bs-border-color, #e9ecef);
    overflow-x: auto;
    scrollbar-width: thin;
    min-height: 40px;
    flex: 0 0 auto;
    /* #page-topbar is position:fixed (70px tall, z-index 1002) and sits
       outside normal document flow. The tab bar lives inside .main-content
       (which already tracks the sidebar's responsive width via its own
       margin-left rules), so only the topbar's height needs accounting for. */
    margin-top: 70px;
    position: relative;
    z-index: 2;
}

.erp-tabs-bar::-webkit-scrollbar {
    height: 4px;
}

.erp-tab {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .6rem .45rem .85rem;
    border-right: 1px solid var(--bs-border-color, #e9ecef);
    white-space: nowrap;
    cursor: pointer;
    font-size: .8125rem;
    color: var(--bs-secondary-color, #74788d);
    max-width: 220px;
    user-select: none;
}

.erp-tab.active {
    background: var(--bs-tertiary-bg, #f3f6f9);
    color: var(--bs-body-color, #343a40);
    font-weight: 600;
    box-shadow: inset 0 -2px 0 var(--bs-primary, #556ee6);
}

.erp-tab-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.erp-tab-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    flex: 0 0 auto;
    font-size: .95rem;
    line-height: 1;
    opacity: .6;
}

.erp-tab-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, .08);
}

/* Small spinner shown in a tab's own label while its iframe is loading —
   visible even for background tabs (e.g. opened via "open in new internal
   tab"), not just the active one. */
.erp-tab-spinner {
    width: 12px;
    height: 12px;
    flex: 0 0 auto;
    border-radius: 50%;
    border: 2px solid rgba(85, 110, 230, .25);
    border-top-color: var(--bs-primary, #556ee6);
    animation: erp-tab-spin .7s linear infinite;
}

@keyframes erp-tab-spin {
    to { transform: rotate(360deg); }
}

.erp-tab-panels {
    position: relative;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}

/* Thin animated progress bar across the top of the content area while the
   *active* tab's iframe is (re)loading. */
.erp-tab-panels.is-loading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 3px;
    width: 40%;
    background: var(--bs-primary, #556ee6);
    z-index: 5;
    animation: erp-tab-progress 1.1s ease-in-out infinite;
}

@keyframes erp-tab-progress {
    0%   { left: -40%; }
    100% { left: 100%; }
}

.erp-tab-panels iframe {
    display: none;
    width: 100%;
    height: 100%;
    border: 0;
}

.erp-tab-panels iframe.active {
    display: block;
}

/* Custom right-click context menu for sidebar links.
   z-index must beat .erp-sidebar-flyout-panel (2147483000 !important, see
   erp-overrides.css) since right-clicking a collapsed-sidebar flyout link
   needs this menu to appear on top of that flyout panel. */
.erp-ctx-menu {
    position: fixed;
    z-index: 2147483001;
    min-width: 200px;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #e9ecef);
    border-radius: .5rem;
    box-shadow: 0 .5rem 1.5rem rgba(0, 0, 0, .18);
    padding: .35rem 0;
    display: none;
}

.erp-ctx-menu.show {
    display: block;
}

.erp-ctx-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: .5rem .9rem;
    border: 0;
    background: none;
    font-size: .8125rem;
    color: var(--bs-body-color, #343a40);
}

.erp-ctx-menu button:hover {
    background: var(--bs-tertiary-bg, #f3f6f9);
}
