/**
 * ERP application chrome — primary white header + thin blue context bar.
 * Uses :root color tokens from custom-colors.css (--primary-color, --primary-rgb, --accent-color).
 */

:root {
    --erp-chrome-header-h: 52px;
    --erp-chrome-context-h: 30px;
    --top-header-height: var(--erp-chrome-header-h);
    --topnav-height: var(--erp-chrome-context-h);
    --header-total-height: calc(var(--erp-chrome-header-h) + var(--erp-chrome-context-h));
}

@media (min-width: 1400px) {
    :root {
        --erp-chrome-header-h: 54px;
        --erp-chrome-context-h: 32px;
    }
}

@media (max-width: 575.98px) {
    :root {
        --erp-chrome-header-h: 48px;
        --erp-chrome-context-h: 32px;
    }
}

/* Centered max-width shell (reference: dense operational frame) */
.erp-app-chrome__inner {
    max-width: 1440px;
    margin-inline: auto;
}

/* Primary white row */
.top-header.elegant-header.erp-app-chrome {
    box-shadow: 0 1px 0 rgba(var(--primary-rgb), 0.1);
    border-bottom: 1px solid rgba(var(--primary-rgb), 0.08);
}

.erp-app-chrome .header-content {
    min-height: var(--erp-chrome-header-h);
    height: var(--erp-chrome-header-h);
    gap: 0.5rem;
    justify-content: flex-start;
}

/* Logo at inline-start (left LTR, right RTL) */
.erp-app-chrome .header-left {
    margin-inline-end: 0;
    padding-inline-end: 0.25rem;
}

.erp-app-chrome .header-nav-links {
    height: 100%;
    margin-inline: 0.25rem;
    min-width: 0;
}

.erp-app-chrome .header-nav-menu {
    gap: 0.25rem;
}

.erp-app-chrome .header-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.35rem 0.55rem;
    font-size: 0.8125rem;
    border-radius: 0.375rem;
}

.erp-app-chrome .header-nav-link i {
    font-size: 0.95rem;
    flex-shrink: 0;
    margin-inline-end: 0;
}

.erp-nav-module-label {
    max-width: 7.5rem;
}

/* Mega panel: column layout follows panel dir (RTL = browse right, signals left) */
.erp-mega-panel__columns {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    direction: inherit;
}

.erp-mega-panel__col {
    min-width: 0;
    padding-inline: 0.625rem;
}

.erp-mega-panel__col--browse {
    flex: 5 1 15rem;
}

.erp-mega-panel__col--quick {
    flex: 3 1 10rem;
}

.erp-mega-panel__col--signals {
    flex: 4 1 12rem;
}

.erp-mega-panel__col + .erp-mega-panel__col {
    border-inline-start: 1px solid var(--bs-border-color-translucent);
}

/* HR mega: dense ERP-style card grid + compact side rail */
.erp-mega-hr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 10.5rem;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem;
    align-items: start;
}

.erp-mega-hr__main {
    min-width: 0;
}

.erp-mega-hr__rail {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    min-width: 0;
    border-inline-start: 1px solid rgba(var(--primary-rgb), 0.12);
    padding-inline-start: 0.5rem;
}

.erp-mega-hr-rail-panel {
    background: rgba(var(--primary-rgb), 0.03);
    border: 1px solid rgba(var(--primary-rgb), 0.1);
    border-radius: 0.375rem;
    padding: 0.4rem 0.45rem;
}

.erp-mega-hr-rail-panel .erp-mega-section-title {
    margin-block-end: 0.25rem;
    font-size: 0.625rem;
}

.erp-mega-hr-rail-panel .mega-quick-link,
.erp-mega-hr-rail-panel .mega-signal-link,
.erp-mega-hr-rail-panel .mega-recent-link {
    display: flex;
    width: 100%;
    padding: 0.15rem 0.2rem;
    font-size: 0.75rem;
    line-height: 1.2;
    gap: 0.2rem;
}

.erp-mega-hr-rail-panel--signals {
    max-height: 11rem;
    overflow-y: auto;
}

.erp-mega-browse-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
    align-items: start;
}

.erp-mega-browse-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bs-body-bg, #fff);
    border: 1px solid rgba(var(--primary-rgb), 0.12);
    border-radius: 0.375rem;
    padding: 0.4rem 0.5rem 0.35rem;
}

.erp-mega-browse-card__title {
    margin: 0;
    text-align: start;
    font-size: 1.1875rem;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--bs-body-color);
    line-height: 1.2;
}

.erp-mega-browse-card__divider {
    height: 1px;
    flex-shrink: 0;
    margin-block: 0.25rem 0.2rem;
    background: rgba(var(--primary-rgb), 0.14);
}

.erp-mega-browse-card__links {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1 1 auto;
}

.erp-mega-browse-card--wide {
    grid-column: span 2;
}

.erp-mega-browse-card--wide .erp-mega-browse-card__links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 0.35rem;
    row-gap: 0;
}

.erp-mega-panel--hr .mega-nav-link--dense {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
    padding: 0.12rem 0.25rem;
    border-radius: 0.25rem;
    color: var(--bs-body-color);
    text-decoration: none;
    font-size: 0.8125rem;
    line-height: 1.25;
    min-height: 1.35rem;
}

.erp-mega-panel--hr .mega-nav-link--dense:hover {
    background: rgba(var(--primary-rgb), 0.08);
    color: var(--primary-color);
}

.erp-mega-panel--hr .mega-nav-link--dense.is-active {
    background: rgba(var(--primary-rgb), 0.12);
    font-weight: 600;
    color: var(--primary-color);
}

.erp-mega-panel--hr .mega-nav-link--dense .badge {
    font-size: 0.625rem;
    padding: 0.1rem 0.3rem;
}

@media (min-width: 1200px) {
    .erp-mega-browse-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .erp-mega-hr {
        grid-template-columns: minmax(0, 1fr) 11rem;
    }
}

@media (max-width: 1099.98px) {
    .erp-mega-hr {
        grid-template-columns: minmax(0, 1fr);
    }

    .erp-mega-hr__rail {
        flex-direction: row;
        flex-wrap: wrap;
        border-inline-start: 0;
        border-block-start: 1px solid rgba(var(--primary-rgb), 0.12);
        padding-inline-start: 0;
        padding-block-start: 0.4rem;
    }

    .erp-mega-hr-rail-panel {
        flex: 1 1 10rem;
    }

    .erp-mega-browse-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 899.98px) {
    .erp-mega-browse-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .erp-mega-browse-card--wide {
        grid-column: span 2;
    }

    .erp-mega-browse-card--wide .erp-mega-browse-card__links {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .erp-mega-browse-card--wide,
    .erp-mega-browse-card--wide .erp-mega-browse-card__links {
        grid-column: auto;
        grid-template-columns: minmax(0, 1fr);
    }
}

.erp-mega-panel--hr .erp-mega-panel__col--browse,
.erp-mega-panel--hr .erp-mega-panel__col--quick,
.erp-mega-panel--hr .erp-mega-panel__col--signals {
    flex: unset;
}

.erp-mega-section-title {
    text-align: start;
    text-transform: uppercase;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--bs-secondary-color);
    margin-block-end: 0.5rem;
    letter-spacing: 0.02em;
}

.erp-mega-subsection-title {
    text-align: start;
    font-size: 0.8125rem;
    font-weight: 600;
    margin-block-end: 0.25rem;
    color: var(--bs-body-color);
}

.erp-mega-muted {
    text-align: start;
}

.erp-mega-link-icon {
    margin-inline-end: 0.25rem;
}

.erp-mega-panel .mega-nav-link {
    text-align: start;
}

.erp-mega-panel .mega-signal-link,
.erp-mega-panel .mega-quick-link,
.erp-mega-panel .mega-recent-link {
    text-align: start;
}

/* Mega panel: anchored under module (inline-start) */
.header-nav-menu .dropdown-menu.erp-mega-panel {
    min-width: min(520px, 92vw) !important;
    max-width: min(880px, 96vw) !important;
    max-height: min(62vh, 26rem);
    overflow-x: hidden;
    overflow-y: auto;
    margin-top: 0.25rem !important;
    padding: 0 !important;
    inset-inline-start: 0;
    inset-inline-end: auto;
}

.header-nav-menu .dropdown-menu.erp-mega-panel--hr {
    min-width: min(860px, 96vw) !important;
    max-width: min(1120px, 98vw) !important;
    max-height: min(68vh, 30rem);
}

.header-nav-menu .dropdown-menu.erp-mega-panel--ltr {
    direction: ltr;
    left: 0 !important;
    right: auto !important;
    inset-inline-start: 0 !important;
    inset-inline-end: auto !important;
}

.header-nav-menu .dropdown-menu.erp-mega-panel--rtl {
    direction: rtl;
    left: auto !important;
    right: 0 !important;
    inset-inline-start: 0 !important;
    inset-inline-end: auto !important;
}

.erp-mega-panel .mega-nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.3rem 0.45rem;
    border-radius: 0.35rem;
    color: #334155;
    text-decoration: none;
    font-size: 0.8125rem;
}

.erp-mega-panel .mega-nav-link:hover {
    background: rgba(var(--primary-rgb), 0.08);
    color: var(--primary-color);
}

.erp-mega-panel .mega-nav-link.is-active {
    background: rgba(var(--primary-rgb), 0.12);
    font-weight: 600;
    color: var(--primary-color);
}

.erp-mega-panel .mega-quick-link,
.erp-mega-panel .mega-signal-link,
.erp-mega-panel .mega-recent-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.8125rem;
}

.erp-mega-panel .mega-signal-link {
    color: #334155;
}

.erp-mega-panel .mega-quick-link:hover,
.erp-mega-panel .mega-signal-link:hover,
.erp-mega-panel .mega-recent-link:hover {
    text-decoration: underline;
}

/* Toolbar — icon-only, compact, at inline-end */
.erp-app-chrome .erp-header-toolbar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-inline-start: auto;
    flex-shrink: 0;
}

.erp-app-chrome .erp-toolbar-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: row;
    min-width: auto;
    padding: 0;
    margin: 0;
}

.erp-app-chrome .erp-toolbar-action .topnav-icon-label {
    display: none !important;
}

.erp-app-chrome .topnav-icon-btn {
    color: var(--primary-color);
    width: 2rem;
    height: 2rem;
    padding: 0;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    border-radius: 0.375rem;
}

.erp-app-chrome .topnav-icon-btn:hover {
    background: rgba(var(--primary-rgb), 0.1);
}

.erp-app-chrome .erp-lang-btn .erp-lang-code {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    line-height: 1;
    color: var(--primary-color);
    margin-inline-start: 0.125rem;
}

.erp-app-chrome .erp-notify-badge {
    font-size: 0.65rem;
    background: var(--accent-color, #f57a36) !important;
}

.erp-app-chrome .erp-notify-menu {
    min-width: 320px;
    max-width: 380px;
}

.erp-app-chrome .erp-notify-list {
    max-height: 320px;
    overflow-y: auto;
}

.erp-app-chrome .logo-img {
    height: 30px;
    width: auto;
    max-width: 150px;
    object-fit: contain;
}

.erp-chrome-menu-btn .fe-menu {
    font-size: 1.35rem;
    line-height: 1;
}

.erp-app-chrome .topnav-profile-avatar-btn {
    padding: 0.1rem;
}

.erp-app-chrome .topnav-profile-avatar-btn .profile-avatar-circle {
    width: 1.7rem;
    height: 1.7rem;
    font-size: 0.68rem;
    border-color: rgba(var(--primary-rgb), 0.35);
}

/* Thin blue context strip — single-line trail */
.topnav-bar.erp-context-subbar {
    height: var(--erp-chrome-context-h) !important;
    min-height: var(--erp-chrome-context-h);
    align-items: stretch;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.erp-context-subbar__inner {
    display: flex;
    align-items: center;
    height: 100%;
    min-height: var(--erp-chrome-context-h);
    padding-block: 0 !important;
}

.topnav-context {
    display: flex;
    align-items: center;
    min-height: 0;
}

.erp-context-trail {
    width: 100%;
    min-width: 0;
    text-align: start;
}

.erp-context-trail__list {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.erp-context-trail__item {
    flex-shrink: 1;
    min-width: 0;
    max-width: 100%;
}

.erp-context-trail__item--current {
    flex-shrink: 0;
    max-width: 55%;
}

.erp-context-trail__sep {
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.42);
    font-size: 0.6875rem;
    padding-inline: 0.3rem;
    user-select: none;
    line-height: 1;
}

.erp-context-trail__link {
    color: rgba(255, 255, 255, 0.82);
    text-decoration: none;
    font-size: 0.75rem;
    line-height: 1.2;
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.erp-context-trail__link:hover {
    color: #fff;
    text-decoration: underline;
}

.erp-context-trail__ancestor {
    font-size: 0.75rem;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.82);
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.erp-context-trail__current {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.2;
    color: #fff;
    min-width: 0;
    max-width: 100%;
}

.erp-context-trail__current i {
    font-size: 0.95em;
    flex-shrink: 0;
    opacity: 0.95;
}

.erp-context-trail__current-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (min-width: 992px) {
    .erp-context-trail__current {
        font-size: 0.875rem;
    }
}

/* Legacy breadcrumb hooks (default variant pages) */
.erp-context-bc {
    padding-bottom: 0;
}

.erp-context-bc .breadcrumb-item,
.erp-context-bc .breadcrumb-item a {
    font-size: 0.6875rem;
    line-height: 1.2;
}

.erp-context-breadcrumb .breadcrumb-item a,
.erp-context-breadcrumb .breadcrumb-item {
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.6875rem;
}

.erp-context-breadcrumb .breadcrumb-item a:hover {
    color: #fff;
    text-decoration: underline;
}

.erp-context-breadcrumb .breadcrumb-item.active {
    color: rgba(255, 255, 255, 0.65);
}

.erp-context-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
    color: rgba(255, 255, 255, 0.45);
}

.topnav-context-toolbar .btn,
.topnav-context-toolbar .btn-group {
    box-shadow: none;
}

.topnav-context-toolbar .btn {
    padding: 0.2rem 0.5rem;
    font-size: 0.8125rem;
}

/* Primary actions on the blue context bar must stay visible */
.topnav-context-toolbar .btn-primary {
    background-color: #fff !important;
    border-color: #fff !important;
    color: var(--primary-color) !important;
}

.topnav-context-toolbar .btn-primary:hover {
    background-color: rgba(255, 255, 255, 0.92) !important;
    border-color: rgba(255, 255, 255, 0.92) !important;
    color: var(--primary-color) !important;
}

/* ── RTL native layout (not mirrored LTR) ── */
[dir="rtl"] .erp-context-trail,
body.rtl .erp-context-trail {
    text-align: right;
}

[dir="rtl"] .erp-context-trail__list,
body.rtl .erp-context-trail__list {
    direction: rtl;
}

[dir="rtl"] .erp-app-chrome .header-content,
body.rtl .erp-app-chrome .header-content {
    flex-direction: row;
}

[dir="rtl"] .erp-app-chrome .header-left,
body.rtl .erp-app-chrome .header-left {
    margin-inline-start: 0;
    margin-inline-end: 0;
}

[dir="rtl"] .erp-app-chrome .erp-header-toolbar,
body.rtl .erp-app-chrome .erp-header-toolbar {
    margin-inline-start: auto;
    margin-inline-end: 0;
}

[dir="rtl"] .erp-app-chrome .header-nav-link,
body.rtl .erp-app-chrome .header-nav-link {
    flex-direction: row;
}

[dir="rtl"] .header-nav-link.dropdown-toggle::after,
body.rtl .header-nav-link.dropdown-toggle::after {
    margin-inline-start: 0.35rem;
    margin-inline-end: 0;
}

[dir="rtl"] .search-overlay-icon,
body.rtl .search-overlay-icon {
    inset-inline-start: 1.25rem;
    inset-inline-end: auto;
    left: auto;
    right: auto;
}

[dir="rtl"] .search-overlay-input,
body.rtl .search-overlay-input {
    padding-inline-start: 3rem;
    padding-inline-end: 3.5rem;
}

[dir="rtl"] .search-overlay-close-btn,
body.rtl .search-overlay-close-btn {
    inset-inline-end: 0.75rem;
    inset-inline-start: auto;
    left: auto;
    right: auto;
}

[dir="rtl"] .erp-sidebar,
body.rtl .erp-sidebar {
    inset-inline-start: 0;
    inset-inline-end: auto;
    left: 0;
    right: auto;
    transform: translateX(-100%);
}

[dir="rtl"] .erp-sidebar.is-open,
body.rtl .erp-sidebar.is-open {
    transform: translateX(0);
}

[dir="rtl"] .profile-dropdown .dropdown-item i,
body.rtl .profile-dropdown .dropdown-item i {
    margin-inline-end: 0.5rem;
    margin-inline-start: 0;
}

/* Search overlay — logical positioning (LTR + RTL) */
.search-overlay-icon {
    inset-inline-start: 1.25rem;
    inset-inline-end: auto;
    left: auto;
    right: auto;
}

.search-overlay-input {
    padding-inline-start: 3rem;
    padding-inline-end: 3.5rem;
}

.search-overlay-close-btn {
    inset-inline-end: 0.75rem;
    inset-inline-start: auto;
    left: auto;
    right: auto;
}

/* Override legacy top-layout column toolbar inside ERP chrome */
.erp-app-chrome .topnav-dropdown-item {
    flex-direction: row;
    min-width: auto;
    padding: 0;
}

/* Global list UX: sortable headers, filters, nav search */
.erp-sort-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: inherit;
    font-weight: 600;
}

.erp-sort-link:hover {
    color: var(--primary-color, #15487B);
}

.erp-sort-link__icon {
    opacity: 0.35;
    font-size: 0.85em;
}

.erp-sort-link__icon.is-active {
    opacity: 1;
    color: var(--primary-color, #15487B);
}

.erp-index-filters .form-label {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.search-overlay-results-container {
    border-top: 1px solid rgba(var(--primary-rgb), 0.08);
}

.search-category-header {
    padding: 0.75rem 1.5rem 0.35rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #6c757d;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 0.7rem 1.5rem;
    color: #212529;
    text-decoration: none;
    border-inline-start: 3px solid transparent;
}

.search-result-item:hover,
.search-result-item:focus {
    background: rgba(var(--primary-rgb), 0.06);
    border-inline-start-color: var(--primary-color, #15487B);
    color: var(--primary-color, #15487B);
}

.erp-mega-module-search {
    margin-bottom: 0.75rem;
}

.erp-mega-module-search__input-wrap {
    position: relative;
}

.erp-mega-module-search__input-wrap .fe-search {
    position: absolute;
    inset-inline-start: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    pointer-events: none;
}

.erp-mega-module-search__input {
    padding-inline-start: 2.25rem;
}

