:root {
    --navy: #2f568c;
    --navy-hover: #274a79;
    --app-header-height: 65px;
    --app-sidebar-rail-width: 72px;
    --app-sidebar-rail-bg: #2b4390;
    --app-sidebar-rail-bg-hover: rgb(255 255 255 / 12%);
}

.layout-shell {
    width: 100%;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 1040;
    background: #ffffff;
}

.app-header.navbar-modern,
.app-header .navbar-modern {
    background: #ffffff;
}

.app-header .navbar-modern .nav-link {
    color: #333333;
    letter-spacing: .2px;
    padding: 4px 8px !important;
    border-radius: 4px !important;
    font-weight: 500;
}

.app-header .navbar-modern .nav-link:hover,
.app-header .navbar-modern .nav-link:focus {
    color: #000000;
    background-color: rgb(150 150 150 / 36%);
    border-radius: .5rem;
}

.app-header .navbar-modern .nav-link.active {
    color: #333333;
    background-color: rgb(155 155 155 / 33%);
    border-radius: .6rem;
}

.app-header .brand-pill {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    border-radius: 1rem;
    padding: .35rem .7rem;
    font-weight: 600;
}

.app-header .icon-btn {
    color: #333333;
    border: 0;
    background: transparent;
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 21px;
}

.app-header .icon-btn:hover {
    background: rgba(15, 23, 42, .06);
    color: #000000;
}

/* Avatar tròn có chữ cái */
.app-header .avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: #1f3d66;
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
}

.app-header-inner {
    min-height: var(--app-header-height);
}

.app-logo {
    height: 36px;
    width: auto;
    display: block;
}


/* Thanh cuộn ẩn nhẹ nhàng cho mobile */
.app-header .scrolling-nav {
    overflow: auto;
    white-space: nowrap;
}

.app-header .scrolling-nav .nav-link {
    display: inline-block;
    margin-right: .25rem;
}

.app-header button.navbar-toggler {
    border: none;
    color: #000;
    font-size: 28px;
    margin-left: 0 !important;
    padding: 0 8px;
}

.app-header button.navbar-toggler:focus {
    box-shadow: none;
}

.app-header #dropdownNotification .notification-item:hover {
    background: #b4d9ff !important;
}

.app-header .navbar-nav .nav-link.show {
    color: #fff;
}

/* DROPDOWN NOTIFICATION */
.app-header .notification-menu {
    width: 420px;
    max-height: 440px;
    padding: 0;
    border-radius: 16px;
    border: none;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .35);
    overflow: hidden;
}

.app-header .notification-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
}

.app-header .notification-header h6 {
    margin: 0;
    font-weight: 600;
}

.app-header .notification-body {
    max-height: 320px;
    overflow-y: auto;
    padding: .5rem 0;
}

.app-header .notification-empty {
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: #6b7280;
}

.app-header .notification-empty-icon {
    font-size: 3rem;
    opacity: .35;
}

.app-header .notification-item {
    border: 0;
    border-radius: 0;
    padding: .75rem 1.25rem;
    cursor: pointer;
    display: flex;
    gap: .75rem;
    align-items: flex-start;
}

.app-header .notification-item:hover {
    background-color: #f3f4ff;
}

.app-header .notification-item.unread .badge-dot {
    background-color: #0d6efd;
}

.app-header .notification-icon {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: #e0ebff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-header .notification-title {
    font-size: .95rem;
    font-weight: 600;
    margin-bottom: .15rem;
}

.app-header .notification-text {
    font-size: .85rem;
    color: #4b5563;
}

.app-header .notification-meta {
    font-size: .78rem;
    color: #9ca3af;
    margin-top: .15rem;
}

.app-header .badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: transparent;
    flex-shrink: 0;
    margin-top: 12px;
}

.app-header .notification-footer {
    border-top: 1px solid #e5e7eb;
    padding: .5rem 1.25rem .75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header .notification-footer .page-info {
    font-size: .8rem;
    color: #6b7280;
}

.app-header .btn-page {
    border-radius: 999px;
    padding: .2rem .7rem;
    font-size: .8rem;
}

@media (min-width: 992px) {

    /* >=lg */
    .app-header .scrolling-nav {
        overflow: visible;
        white-space: normal;
    }
}

@media (max-width: 576px) {
    .app-header .notification-menu {
        right: -139px !important;
    }

    #dropdownCart {
        right: -132px !important;
        width: min(92vw, 420px);
    }
}

/*-------------CART--------------*/
.app-header #dropdownCart {
    width: 420px;
    min-width: 420px;
    max-width: min(92vw, 420px);
    border-radius: 20px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .18);
}

.dropdown-cart-panel {
    background: #ffffff;
}

.dropdown-cart-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

.dropdown-cart-title-wrap {
    display: flex;
    align-items: center;
    gap: .85rem;
    min-width: 0;
}

.dropdown-cart-title-wrap h6 {
    margin: 0;
    font-weight: 700;
    color: #0f172a;
}

.dropdown-cart-title-wrap p {
    font-size: .82rem;
    line-height: 1.35;
}

.dropdown-cart-title-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #e8f1ff;
    color: var(--primary);
    font-size: 1.15rem;
    flex-shrink: 0;
}

.dropdown-cart-count-badge {
    border-radius: 999px;
    padding: .45rem .75rem;
    background: #eef2ff;
    color: #4338ca;
    font-size: .78rem;
    font-weight: 700;
    white-space: nowrap;
}

.dropdown-cart-body {
    max-height: 340px;
    overflow-y: auto;
    padding: .75rem;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.dropdown-cart-body::-webkit-scrollbar {
    width: 8px;
}

.dropdown-cart-body::-webkit-scrollbar-track {
    background: transparent;
}

.dropdown-cart-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
    border: 2px solid #ffffff;
}

.dropdown-cart-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.dropdown-cart-empty {
    padding: 2.75rem 1.5rem 2.25rem;
    text-align: center;
}

.dropdown-cart-empty-icon {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
    border-radius: 1.25rem;
    background: #f3f4f6;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}

.dropdown-cart-empty-title {
    font-weight: 700;
    color: #0f172a;
    margin-bottom: .4rem;
}

.dropdown-cart-empty-text {
    color: #6b7280;
    font-size: .9rem;
    line-height: 1.5;
    max-width: 290px;
    margin: 0 auto;
}

.dropdown-cart-body .cart-item {
    transition: background-color 0.15s, border-color 0.15s, transform 0.15s;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: .85rem;
    background: #ffffff;
}

.dropdown-cart-body .cart-item + .cart-item {
    margin-top: .75rem;
}

.dropdown-cart-body .cart-item:hover {
    background-color: #f8fbff;
    border-color: #cfe0ff;
    transform: translateY(-1px);
}

.cart-item-main {
    display: flex;
    align-items: center;
    gap: .85rem;
}

.cart-item-img-container {
    width: 72px;
    height: 72px;
    background: #f8fafc;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.cart-item-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-item-content {
    flex: 1;
    min-width: 0;
}

.cart-item-top-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .3rem;
}

.cart-item-code {
    display: inline-flex;
    align-items: center;
    padding: .2rem .55rem;
    border-radius: 999px;
    background: #f3f4f6;
    color: #475569;
    font-size: .74rem;
    font-weight: 600;
}

.cart-item-name {
    font-size: .95rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    color: #0f172a;
    font-size: .88rem;
}

.cart-item-qty-label {
    color: #6b7280;
}

.btn-delete-item {
    width: 2rem;
    height: 2rem;
    line-height: 1;
    font-size: 1rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn-delete-item:hover {
    background: rgba(220, 53, 69, .08);
}

.dropdown-cart-footer {
    border-top: 1px solid #e5e7eb;
    padding: 1rem 1.25rem 1.25rem;
    background: #fcfcfd;
}

.dropdown-cart-footer-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .9rem;
    color: #64748b;
    font-size: .85rem;
}

.dropdown-cart-footer-summary strong {
    color: #111827;
    font-size: .9rem;
}

.dropdown-cart-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .65rem;
}

.dropdown-cart-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    border-radius: 12px;
    font-weight: 600;
    padding-left: .75rem;
    padding-right: .75rem;
    white-space: nowrap;
}

@media (max-width: 576px) {
    .app-header #dropdownCart {
        min-width: min(92vw, 420px);
    }

    .dropdown-cart-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .dropdown-cart-count-badge {
        align-self: flex-start;
    }
}

/*-------------LAYOUT APP-------------*/
.app-container {
    min-height: 100vh;
}

.app-shell {
    height: calc(100vh - var(--app-header-height));
    min-height: calc(100vh - var(--app-header-height));
    overflow: hidden;
}

/*-------------SIDEBAR RAIL + FLYOUT-------------*/
.app-sidebar {
    display: flex;
    width: var(--app-sidebar-rail-width);
    flex-shrink: 0;
    height: 100%;
    z-index: 1030;
    min-height: 0;
    position: relative;
    background: var(--app-sidebar-rail-bg);
}

.app-sidebar-backdrop {
    position: fixed;
    inset: var(--app-header-height) 0 0 0;
    background: rgba(15, 23, 42, 0.42);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1025;
}

/* Thanh rail: mỗi mục cấp 1 = icon + nhãn nhỏ dựng đứng (theo mẫu). */
.sidebar-rail {
    min-height: 0;
    overflow-y: auto;
    flex: 1 1 auto;
    padding: .75rem 0 1rem;
}

.sidebar-rail-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.sidebar-rail-item {
    position: relative;
}

.rail-link {
    width: 100%;
    min-height: 66px;
    padding: 0 .35rem;
    border: 0;
    background: transparent;
    color: rgb(255 255 255 / 88%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.rail-link:hover,
.rail-link:focus-visible {
    background: var(--app-sidebar-rail-bg-hover);
    color: #fff;
}

.rail-link.active {
    background: rgb(255 255 255 / 18%);
    color: #fff;
}

.rail-icon {
    font-size: 1.35rem;
    line-height: 1;
}

.rail-label {
    font-size: .68rem;
    line-height: 1.15;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Flyout menu con — JS đặt position:fixed sát mép phải rail để không bị overflow của .sidebar-rail cắt. */
.sidebar-flyout {
    display: none;
    position: fixed;
    z-index: 1045;
    min-width: 240px;
    max-width: 320px;
    max-height: calc(100vh - var(--app-header-height) - 16px);
    overflow-y: auto;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 14px 38px rgba(15, 23, 42, .22);
    padding: .5rem 0;
}

.sidebar-flyout.open {
    display: block;
}

.sidebar-flyout-group {
    padding: .6rem 1.25rem .25rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: #8a94a6;
}

.flyout-link {
    display: block;
    padding: .55rem 1.25rem;
    color: var(--navy);
    font-size: .92rem;
    font-weight: 500;
    text-decoration: none;
}

.flyout-link:hover,
.flyout-link:focus-visible {
    background: #f1f4f9;
    color: var(--navy-hover);
}

.flyout-link.active {
    font-weight: 700;
    color: var(--navy-hover);
}

.sidebar-footer {
    flex-shrink: 0;
    background: #ffffff;
}

.app-content-wrapper {
    min-width: 0;
    /* Giúp nội dung không bị trào ra ngoài flex container */
    background: #f7f8fb;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
}

@media (min-width: 992px) {
    .app-sidebar-backdrop {
        display: none;
    }
}

@media (max-width: 991.98px) {
    /* Drawer mobile = đúng bề rộng rail. Dùng "left" thay "transform": ancestor có transform
       sẽ biến flyout position:fixed thành định vị theo sidebar → lệch tọa độ. */
    .app-sidebar {
        position: fixed;
        top: var(--app-header-height);
        left: calc(-1 * var(--app-sidebar-rail-width));
        width: var(--app-sidebar-rail-width);
        height: calc(100vh - var(--app-header-height));
        transition: left 0.25s ease;
        box-shadow: 0 20px 45px rgba(15, 23, 42, 0.18);
        z-index: 1030;
    }

    .app-shell {
        height: auto;
        min-height: auto;
        overflow: visible;
    }

    .app-content-wrapper {
        height: auto;
        overflow: visible;
    }

    .app-sidebar {
        min-height: 0;
    }

    .mobile-sidebar-open .app-sidebar {
        left: 0;
    }

    .mobile-sidebar-open .app-sidebar-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .sidebar-footer {
        display: none !important;
    }
}

/*--------------------------------------------------------
-------------------LANGUAGE SWITCHER----------------------
----------------------------------------------------------
*/
.app-header .icon-btn.icon-lang:hover {
    background: transparent;
}

.app-language-switcher .app-language-toggle {
    width: auto;
    min-width: 3.75rem;
    height: 2.25rem;
    padding: .35rem .55rem;
    border-radius: 999px;
    gap: .4rem;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    font-size: .85rem;
    font-weight: 700;
}

    .app-language-switcher .app-language-toggle:hover,
    .app-language-switcher .app-language-toggle:focus {
        background: #f1f5f9;
        color: #111827;
    }

.app-language-switcher .app-language-menu {
    min-width: 9rem;
    padding: .4rem;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .16);
}

.app-language-switcher .app-language-item {
    display: flex;
    align-items: center;
    gap: .55rem;
    border-radius: 10px;
    padding: .55rem .7rem;
    font-weight: 600;
}

    .app-language-switcher .app-language-item.active,
    .app-language-switcher .app-language-item:active {
        background: #eef2ff;
        color: #1e3a8a;
    }

.app-language-flag {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.app-language-code {
    line-height: 1;
}

.app-language-chevron {
    font-size: .7rem;
}
