/* Global UI enhancements: Bootstrap Icons spacing, tables, cards */

/* Global page content inset */
.app-content-inner {
    width: 100%;
    max-width: 100%;
    padding: clamp(0.75rem, 2vw, 1.25rem);
    box-sizing: border-box;
    animation: app-page-enter 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes app-page-enter {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-content-inner {
        animation: none;
    }
}

.modal {
    z-index: 1075;
}

.modal-backdrop {
    z-index: 1070;
}

/* Page transition: NProgress top bar (brand palette) */
#nprogress {
    pointer-events: none;
}

#nprogress .bar {
    background: linear-gradient(90deg, var(--brand-dark, #446078) 0%, var(--brand, #077ba1) 45%, #38bdf8 100%);
    box-shadow: 0 0 12px rgba(7, 123, 161, 0.45);
    height: 3px;
    z-index: 12000;
}

#nprogress .peg {
    box-shadow:
        0 0 12px rgba(7, 123, 161, 0.65),
        0 0 4px rgba(7, 123, 161, 0.85);
}

html[data-theme='dark'] #nprogress .bar {
    background: linear-gradient(90deg, #5ec4e8 0%, var(--brand, #077ba1) 55%, #93c5fd 100%);
    box-shadow: 0 0 14px rgba(94, 196, 232, 0.35);
}

html[data-theme='dark'] #nprogress .peg {
    box-shadow:
        0 0 12px rgba(94, 196, 232, 0.55),
        0 0 4px rgba(94, 196, 232, 0.75);
}

body.is-page-navigating .app-main {
    pointer-events: none;
}

/* Table shell: inset tables from card/container edges */
.table-margin-wrap {
    padding: 0.75rem 1rem;
}

.table-margin-wrap > .table,
.table-margin-wrap .table {
    margin-bottom: 0;
}

.app-content-inner .card-body.p-0 > .table-margin-wrap,
.app-content-inner .card-body.p-0 > .table-responsive:not(.inventory-table-scroll):not(.inventory-table-shell),
.app-content-inner .card-body.p-0 > .inventory-table-scroll:not(.inventory-table-shell) {
    padding: 0.75rem 1rem;
}

.app-sidebar {
    display: flex;
    flex-direction: column;
    padding: 0;
}

.app-sidebar__brand {
    flex-shrink: 0;
    padding: 1.25rem 1rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.app-sidebar__brand .brand {
    margin-bottom: 0;
}

.app-sidebar__nav {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: scroll;
    padding: 0.75rem 1rem 1.25rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.app-sidebar__nav::-webkit-scrollbar {
    width: 6px;
}

.app-sidebar__nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.28);
    border-radius: 999px;
}

.app-sidebar__nav::-webkit-scrollbar-track {
    background: transparent;
}

.app-sidebar__nav--mobile {
    flex: 1;
    min-height: 0;
    padding: 1rem;
    overflow-x: hidden;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.app-sidebar__footer--mobile {
    flex-shrink: 0;
    padding: 0 1rem 1rem;
}

#mobileSidebar .offcanvas-body {
    overflow: hidden;
}

.side-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

button.side-link {
    appearance: none;
    font: inherit;
    font-family: inherit;
}

.side-link i,
.side-nav-accordion__label i {
    width: 1.1rem;
    text-align: center;
    flex-shrink: 0;
    font-size: 1rem;
    opacity: 0.95;
}

.page-title-with-icon {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0;
}

.page-title-with-icon i {
    color: var(--brand, #077ba1);
}

.card.shadow-sm-ui,
.inventory-filter-card,
.inventory-table-card {
    border: 1px solid var(--border-soft, #d9e6ef);
    border-radius: 12px;
    box-shadow: 0 4px 18px -10px rgba(68, 96, 120, 0.22);
    overflow: hidden;
}

.table-sticky thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.inventory-code code,
code.inventory-code-tag {
    font-size: 0.85rem;
    color: var(--brand, #077ba1);
    font-weight: 700;
    background: rgba(7, 123, 161, 0.08);
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
}

.btn i.bi {
    line-height: 1;
}

.btn i.bi:first-child:not(:last-child) {
    margin-right: 0.35rem;
}

html[data-theme='dark'] .table-sticky thead th {
    background: var(--theme-surface-elevated, #1a2d3d);
    box-shadow: inset 0 1px 0 var(--theme-border, #2a3d4d), inset 0 -1px 0 var(--theme-border, #2a3d4d);
}

html[data-theme='dark'] .card.shadow-sm-ui,
html[data-theme='dark'] .inventory-filter-card,
html[data-theme='dark'] .inventory-table-card {
    border-color: var(--theme-border, #2a3d4d);
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.25);
}

.side-link--soon {
    opacity: 0.78;
    cursor: not-allowed;
    pointer-events: none;
}

/* Sidebar palette (Avante gradient; independent of page light/dark surfaces) */
.app-sidebar,
#mobileSidebar {
    --sidebar-fg: #ffffff;
    --sidebar-fg-muted: rgba(255, 255, 255, 0.9);
    --sidebar-fg-subtle: rgba(255, 255, 255, 0.78);
    --sidebar-item-bg: rgba(255, 255, 255, 0.1);
    --sidebar-item-border: rgba(255, 255, 255, 0.22);
    --sidebar-item-hover-bg: rgba(255, 255, 255, 0.2);
    --sidebar-item-active-bg: rgba(255, 255, 255, 0.22);
    --sidebar-item-current-border: var(--accent, #bb0808);
    --sidebar-dropdown-bg: rgba(0, 48, 68, 0.42);
    --sidebar-dropdown-border: rgba(255, 255, 255, 0.16);
    --sidebar-soon-badge-bg: rgba(255, 255, 255, 0.95);
    --sidebar-soon-badge-fg: #2f4f61;
    background: linear-gradient(180deg, var(--theme-sidebar-start, #0b86af) 0%, var(--theme-sidebar-end, #446078) 100%) !important;
    color: var(--sidebar-fg);
}

html[data-theme='dark'] .app-sidebar,
html[data-theme='dark'] #mobileSidebar {
    --sidebar-fg: #ecf6fb;
    --sidebar-fg-muted: rgba(236, 246, 251, 0.92);
    --sidebar-fg-subtle: rgba(236, 246, 251, 0.8);
    --sidebar-item-bg: rgba(255, 255, 255, 0.07);
    --sidebar-item-border: rgba(255, 255, 255, 0.18);
    --sidebar-item-hover-bg: rgba(57, 166, 201, 0.24);
    --sidebar-item-active-bg: rgba(255, 255, 255, 0.12);
    --sidebar-item-current-border: var(--accent, #bb0808);
    --sidebar-dropdown-bg: rgba(0, 0, 0, 0.32);
    --sidebar-dropdown-border: rgba(255, 255, 255, 0.14);
    --sidebar-soon-badge-bg: rgba(12, 32, 44, 0.92);
    --sidebar-soon-badge-fg: #c5dce8;
}

.app-sidebar .brand,
#mobileSidebar .offcanvas-title {
    color: var(--sidebar-fg) !important;
}

.app-sidebar .side-link,
#mobileSidebar .side-link {
    color: var(--sidebar-fg-muted) !important;
    border-color: var(--sidebar-item-border) !important;
    background: var(--sidebar-item-bg);
}

.app-sidebar .side-link:hover,
.app-sidebar .side-link:focus,
#mobileSidebar .side-link:hover,
#mobileSidebar .side-link:focus {
    color: var(--sidebar-fg) !important;
    background: var(--sidebar-item-hover-bg);
    border-color: var(--sidebar-item-border) !important;
}

.app-sidebar .side-link.active,
#mobileSidebar .side-link.active {
    color: var(--sidebar-fg) !important;
    background: var(--sidebar-item-active-bg);
    border: 2px solid var(--sidebar-item-current-border) !important;
    font-weight: 600;
}

.app-sidebar .btn-sidebar-logout,
#mobileSidebar .btn-sidebar-logout {
    color: var(--sidebar-fg) !important;
    background: var(--sidebar-item-bg);
    border: 1px solid var(--sidebar-item-border);
}

.app-sidebar .btn-sidebar-logout:hover,
.app-sidebar .btn-sidebar-logout:focus,
#mobileSidebar .btn-sidebar-logout:hover,
#mobileSidebar .btn-sidebar-logout:focus {
    color: var(--sidebar-fg) !important;
    background: var(--sidebar-item-hover-bg);
    border-color: var(--sidebar-item-border);
}

/* Sidebar: Bootstrap accordion module groups */
.side-nav-accordion {
    --bs-accordion-bg: transparent;
    --bs-accordion-border-color: transparent;
    --bs-accordion-border-width: 0;
    --bs-accordion-btn-padding-x: 0.75rem;
    --bs-accordion-btn-padding-y: 0.55rem;
    --bs-accordion-body-padding-x: 0.4rem;
    --bs-accordion-body-padding-y: 0.4rem;
    --bs-accordion-active-color: var(--sidebar-fg);
    --bs-accordion-active-bg: var(--sidebar-item-active-bg);
    --bs-accordion-btn-focus-box-shadow: none;
    --bs-accordion-btn-icon-width: 0.72rem;
    --bs-accordion-btn-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23ffffff'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708'/%3e%3c/svg%3e");
    --bs-accordion-btn-active-icon: var(--bs-accordion-btn-icon);
    margin-bottom: 0.55rem;
}

.side-nav-accordion__item {
    margin-bottom: 0.55rem;
    border: 0;
    background: transparent;
}

.side-nav-accordion__item:last-child {
    margin-bottom: 0;
}

.side-nav-accordion .accordion-header {
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
}

.side-nav-accordion__toggle {
    display: flex;
    align-items: center;
    width: 100%;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    border: 1px solid var(--sidebar-item-border) !important;
    border-radius: 10px !important;
    color: var(--sidebar-fg-muted) !important;
    background: var(--sidebar-item-bg) !important;
    box-shadow: none !important;
}

.side-nav-accordion__toggle:not(.collapsed),
.side-nav-accordion__toggle:hover,
.side-nav-accordion__toggle:focus {
    color: var(--sidebar-fg) !important;
    background: var(--sidebar-item-hover-bg) !important;
    border-color: var(--sidebar-item-border) !important;
    box-shadow: none !important;
}

.side-nav-accordion__toggle.active:not(.collapsed) {
    background: var(--sidebar-item-active-bg) !important;
    font-weight: 600;
}

.side-nav-accordion__toggle::after {
    margin-left: auto;
    filter: brightness(1.15);
}

.side-nav-accordion__label {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.side-nav-accordion__body {
    margin-top: 0.35rem;
    padding: 0.4rem;
    border-radius: 10px;
    background: var(--sidebar-dropdown-bg);
    border: 1px solid var(--sidebar-dropdown-border);
}

.side-nav-accordion .accordion-collapse {
    border: 0;
}

.app-sidebar .side-nav-link,
#mobileSidebar .side-nav-link {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.42rem 0.6rem;
    margin-bottom: 0.2rem;
    border-radius: 8px;
    color: var(--sidebar-fg-muted);
    text-decoration: none;
    font-size: 0.84rem;
    border: 1px solid transparent;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.app-sidebar .side-nav-link:last-child,
#mobileSidebar .side-nav-link:last-child {
    margin-bottom: 0;
}

.app-sidebar .side-nav-link i,
#mobileSidebar .side-nav-link i {
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
    font-size: 0.9rem;
}

.app-sidebar .side-nav-link:hover,
.app-sidebar .side-nav-link:focus,
#mobileSidebar .side-nav-link:hover,
#mobileSidebar .side-nav-link:focus {
    color: var(--sidebar-fg);
    background: var(--sidebar-item-hover-bg);
    border-color: var(--sidebar-item-border);
}

.app-sidebar .side-nav-link.active,
#mobileSidebar .side-nav-link.active {
    color: var(--sidebar-fg);
    background: var(--sidebar-item-active-bg);
    border: 2px solid var(--sidebar-item-current-border);
    font-weight: 600;
}

.side-nav-link--soon {
    color: var(--sidebar-fg-subtle) !important;
    cursor: not-allowed;
    pointer-events: none;
}

.sidebar-soon-badge {
    margin-left: auto;
    font-size: 0.58rem;
    padding: 0.2em 0.45em;
    border-radius: 999px;
    font-weight: 600;
    background: var(--sidebar-soon-badge-bg) !important;
    color: var(--sidebar-soon-badge-fg) !important;
}

.app-sidebar .text-dark,
#mobileSidebar .text-dark,
.app-sidebar .bg-light,
#mobileSidebar .bg-light,
.app-sidebar .text-bg-light,
#mobileSidebar .text-bg-light {
    color: var(--sidebar-fg-muted) !important;
    background-color: var(--sidebar-item-bg) !important;
}

#mobileSidebar .topbar-user-role,
#mobileSidebar .operation-counter,
#mobileSidebar .theme-toggle-btn {
    color: var(--sidebar-fg-muted) !important;
    border-color: var(--sidebar-item-border) !important;
    background: var(--sidebar-item-bg) !important;
}

#mobileSidebar .theme-toggle-btn:hover,
#mobileSidebar .theme-toggle-btn:focus {
    color: var(--sidebar-fg) !important;
    background: var(--sidebar-item-hover-bg) !important;
    border-color: var(--sidebar-item-border) !important;
}
