/* =========================================================
   LAYOUT STYLE - DESKTOP GLASS NAVBAR + MOBILE GLASS SIDEBAR
   ========================================================= */
:root {
    --app-font-display: "Space Grotesk", "Segoe UI", sans-serif;
    --app-font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
    --app-font-mono: "JetBrains Mono", Consolas, monospace;
}

body { font-family: var(--app-font-body); }
h1, h2, h3, h4, h5, h6 { font-family: var(--app-font-display); }
code, pre, .font-monospace { font-family: var(--app-font-mono); }

/* Dùng cho mọi tiêu đề/nhãn/số liệu nổi bật ở bất kỳ blade nào (thay vì khai báo
   font-family: var(--app-font-display) lặp lại trong từng file) — chỉ gắn class
   này vào thẻ, không cần style riêng. */
.text-display { font-family: var(--app-font-display); }

/* Avatar frame wrap (used in the header/dropdown user avatars) */
.app-avatar-wrap {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    width: var(--avatar-size, 40px);
    height: var(--avatar-size, 40px);
}

.app-avatar-wrap > img:not(.app-avatar-frame) {
    position: relative;
    z-index: 1;
    border-radius: 50% !important;
}

.app-avatar-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    width: calc(var(--avatar-size, 40px) * 1.35);
    height: calc(var(--avatar-size, 40px) * 1.35);
    max-width: none;
    transform: translate(-50%, -50%);
    object-fit: contain;
    pointer-events: none;
    z-index: 2;
}

/* Mobile bottom navigation */
.mobile-bottom-nav { display: none; }

@media (max-width: 991.98px) {
    body { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }

    .mobile-bottom-nav {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: calc(10px + env(safe-area-inset-bottom));
        z-index: 1040;
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
        padding: 8px;
        border: 1px solid rgba(148, 163, 184, .22);
        border-radius: 22px;
        background: rgba(255, 255, 255, .92);
        box-shadow: 0 18px 45px rgba(15, 23, 42, .16);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
    }

    .mobile-bottom-nav__item {
        min-width: 0;
        min-height: 54px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        border-radius: 16px;
        color: #64748b;
        text-decoration: none;
        font-size: 11px;
        font-weight: 800;
        line-height: 1.1;
        transition: color .16s ease, background .16s ease, transform .16s ease, box-shadow .16s ease;
    }

    .mobile-bottom-nav__item i {
        width: 28px;
        height: 28px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 12px;
        background: #f1f5f9;
        color: #64748b;
        font-size: 18px;
        transition: color .16s ease, background .16s ease, transform .16s ease;
    }

    .mobile-bottom-nav__item span {
        display: block;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-bottom-nav__item:hover,
    .mobile-bottom-nav__item.active {
        color: #2563eb;
        background: rgba(37, 99, 235, .08);
        transform: translateY(-1px);
    }

    .mobile-bottom-nav__item:hover i,
    .mobile-bottom-nav__item.active i {
        color: #ffffff;
        background: linear-gradient(135deg, #2563eb, #0ea5e9);
        box-shadow: 0 8px 18px rgba(37, 99, 235, .22);
    }

    [data-pc-theme="dark"] .mobile-bottom-nav {
        border-color: rgba(148, 163, 184, .18);
        background: rgba(15, 23, 42, .90);
        box-shadow: 0 18px 45px rgba(0, 0, 0, .34);
    }

    [data-pc-theme="dark"] .mobile-bottom-nav__item { color: #94a3b8; }

    [data-pc-theme="dark"] .mobile-bottom-nav__item i {
        background: rgba(30, 41, 59, .94);
        color: #94a3b8;
    }

    [data-pc-theme="dark"] .mobile-bottom-nav__item:hover,
    [data-pc-theme="dark"] .mobile-bottom-nav__item.active {
        color: #93c5fd;
        background: rgba(96, 165, 250, .12);
    }

    #support-button { bottom: calc(92px + env(safe-area-inset-bottom)); }
}

.avatar-img { width: 40px; height: 40px; object-fit: cover; border-radius: 50%; display: block; transition: 0.3s; }
        
/* Sửa lỗi méo ảnh avatar ở dropdown và mobile */
.user-avtar {
    width: 45px !important; /* Bạn có thể tuỳ chỉnh kích thước */
    height: 45px !important;
    border-radius: 50% !important;
    object-fit: cover !important; /* Thuộc tính quan trọng nhất để ảnh không bị méo */
    aspect-ratio: 1 / 1; /* Ép tỷ lệ 1:1 */
}

/* Nếu có thêm viền (border) ở dropdown profile như trong ảnh */
.dropdown-user-profile .user-avtar {
    width: 55px !important;
    height: 55px !important;
}

@media (min-width: 992px) {
    .pc-sidebar, .pc-header { display: none !important; }
    .pc-container { margin-left: 0 !important; padding-top: 20px !important; margin-top: var(--frontend-navbar-offset, 96px); }
    
    .desktop-navbar-wrapper {
        position: fixed; top: 15px; left: 50%; transform: translateX(-50%); width: min(96%, 1440px); z-index: 1020; padding: 14px 22px;
        display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 18px;
        background: rgba(255, 255, 255, 0.6) !important; backdrop-filter: blur(10px) saturate(130%);
        -webkit-backdrop-filter: blur(10px) saturate(130%); border-radius: 20px;
        border: 1px solid rgba(255, 255, 255, 0.5); border-top: 1px solid rgba(255, 255, 255, 0.9);
        box-shadow: 0 8px 24px rgba(31, 38, 135, 0.06); transition: all 0.3s ease;
    }
    .nav-brand-area { justify-self: start; min-width: fit-content; }
    .nav-brand { display: inline-flex; align-items: center; }
    .nav-brand img { height: 38px; max-width: 100%; object-fit: contain; }
    
    .modern-menu-area { min-width: 0; width: 100%; display: flex; justify-content: center; align-items: center; position: relative; }
    .modern-menu { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; list-style: none; margin: 0; padding: 0; width: 100%; }
    .modern-item { position: relative; flex: 0 0 auto; }
    .modern-link {
        display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 12px; color: #475569;
        font-family: var(--app-font-display); font-weight: 600; font-size: 13.5px; line-height: 1.2; text-decoration: none; white-space: nowrap; transition: all 0.25s ease;
    }
    .modern-link-button {
        appearance: none;
        -webkit-appearance: none;
        border: 0 !important;
        outline: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
        background-color: transparent !important;
        background-image: none !important;
        font-family: inherit;
        cursor: pointer;
    }
    .modern-link-button:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: 2px; }
    .modern-link:hover, .modern-link.active { background: rgba(13, 110, 253, 0.1); color: var(--bs-primary) !important; transform: translateY(-2px); }
    .modern-link img, .category-nav-icon, .modern-link__icon { width: 22px; height: 22px; flex: 0 0 auto; }
    .modern-link img { object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1)); }
    .category-nav-icon { display: inline-flex; align-items: center; justify-content: center; }
    .category-nav-icon i { font-size: 20px; line-height: 1; color: currentColor; }
    .modern-link__icon { display: inline-flex; align-items: center; justify-content: center; font-size: 18px; line-height: 1; color: currentColor; }
    
    .modern-dropdown {
        position: absolute; top: calc(100% + 14px); left: 50%; transform: translateX(-50%) translateY(12px); min-width: 240px; max-width: 280px;
        border-radius: 16px; padding: 12px; opacity: 0; visibility: hidden; z-index: 1035; transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
        background: rgba(255, 255, 255, 0.7) !important; backdrop-filter: blur(10px) saturate(130%);
        -webkit-backdrop-filter: blur(10px) saturate(130%); border: 1px solid rgba(255, 255, 255, 0.5) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.9) !important; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.08);
    }

    /* FIX LỖI MẤT HOVER: Cầu nối tàng hình để không bị đứt đoạn khi rê chuột xuống Menu con */
    .modern-dropdown::before {
        content: ''; position: absolute; top: -20px; left: 0; right: 0; height: 20px; background: transparent;
    }

    .modern-item:nth-last-child(1) .modern-dropdown, .modern-item:nth-last-child(2) .modern-dropdown, .modern-item:nth-last-child(3) .modern-dropdown { left: auto; right: 0; transform: translateY(12px); }
    .modern-item:hover, .modern-item:focus-within { z-index: 1036; }
    .modern-item:hover .modern-dropdown, .modern-item:focus-within .modern-dropdown { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
    .modern-item:nth-last-child(1):hover .modern-dropdown, .modern-item:nth-last-child(2):hover .modern-dropdown, .modern-item:nth-last-child(3):hover .modern-dropdown,
    .modern-item:nth-last-child(1):focus-within .modern-dropdown, .modern-item:nth-last-child(2):focus-within .modern-dropdown, .modern-item:nth-last-child(3):focus-within .modern-dropdown { transform: translateY(0); }
    
    .dropdown-link { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px; color: #475569; text-decoration: none; font-family: var(--app-font-display); font-size: 13.5px; font-weight: 500; transition: 0.2s; }
    .dropdown-link:hover { background: rgba(13, 110, 253, 0.1); color: var(--bs-primary); padding-left: 18px; }
    .dropdown-divider { border-top: 1px solid rgba(0, 0, 0, 0.06); margin: 8px 0; }
    
    .user-action-area { justify-self: end; display: flex; align-items: center; justify-content: flex-end; gap: 15px; min-width: fit-content; }
    .theme-btn { background: rgba(255, 255, 255, 0.5); border: 1px solid rgba(255, 255, 255, 0.8); color: #475569; cursor: pointer; padding: 10px; border-radius: 50%; transition: 0.3s; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); }
    .theme-btn:hover { background: rgba(255, 255, 255, 0.9); transform: rotate(15deg) scale(1.1); color: var(--bs-primary); }
    .dropdown-toggle:hover .avatar-img { transform: scale(1.05); box-shadow: 0 0 15px rgba(13, 110, 253, 0.3); }
}

@media (min-width: 992px) and (max-width: 1260px) {
    .desktop-navbar-wrapper { padding: 12px 16px; gap: 14px; } .modern-menu { gap: 6px; }
    .modern-link { padding: 9px 11px; font-size: 13px; } .modern-link img, .category-nav-icon, .modern-link__icon { width: 20px; height: 20px; } .modern-link__icon { font-size: 16px; }
    .nav-brand img { height: 34px; }
}

.pc-sidebar .category-nav-icon i { font-size: 20px; color: currentColor; }

@media (max-width: 991.98px) {
    .desktop-navbar-wrapper { display: none !important; }
    .pc-sidebar, .pc-header { display: block !important; }
    .pc-header, .pc-sidebar, .pc-sidebar .navbar-wrapper {
        background: rgba(255, 255, 255, 0.65) !important; backdrop-filter: blur(10px) saturate(130%); -webkit-backdrop-filter: blur(10px) saturate(130%);
    }
    .pc-header { border-bottom: 1px solid rgba(255, 255, 255, 0.5) !important; }
    .pc-sidebar { border-right: 1px solid rgba(255, 255, 255, 0.5) !important; box-shadow: 4px 0 18px rgba(0, 0, 0, 0.04); }
}

/* =========================================================
   MOBILE SIDEBAR + HEADER — Modern SaaS Dashboard sync
   ========================================================= */
.pc-sidebar {
    --nav-primary: #2563eb;
    --nav-primary-2: #0ea5e9;
    --nav-text: #0f172a;
    --nav-muted: #64748b;
    --nav-chip: rgba(37, 99, 235, .10);
}

[data-pc-theme="dark"] .pc-sidebar {
    --nav-primary: #60a5fa;
    --nav-primary-2: #22d3ee;
    --nav-text: #e5edf7;
    --nav-muted: #94a3b8;
    --nav-chip: rgba(96, 165, 250, .14);
}

.pc-sidebar .pc-navbar { padding: 10px 12px; }

.pc-sidebar .pc-item.pc-caption { padding: 14px 10px 6px; }
.pc-sidebar .pc-item.pc-caption label {
    color: var(--nav-primary) !important;
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin: 0;
}

.pc-sidebar .pc-navbar > .pc-item { margin: 3px 0; }

.pc-sidebar .pc-item .pc-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 14px;
    color: var(--nav-text);
    font-weight: 700;
    font-size: .95rem;
    transition: background .16s ease, color .16s ease;
}

.pc-sidebar .pc-item .pc-micon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: var(--nav-chip);
    color: var(--nav-primary);
    font-size: 1.1rem;
    transition: background .16s ease, color .16s ease;
}

.pc-sidebar .pc-item .pc-micon img { width: 19px; height: 19px; object-fit: contain; }
.pc-sidebar .pc-item .pc-mtext { font-family: var(--app-font-body, inherit); }

.pc-sidebar .pc-navbar > .pc-item > .pc-link:hover,
.pc-sidebar .pc-navbar > .pc-item.active > .pc-link,
.pc-sidebar .pc-navbar > .pc-item.pc-hasmenu.pc-trigger > .pc-link {
    background: linear-gradient(135deg, var(--nav-primary), var(--nav-primary-2)) !important;
    color: #fff !important;
}

.pc-sidebar .pc-navbar > .pc-item.active > .pc-link:after { display: none; }

.pc-sidebar .pc-navbar > .pc-item > .pc-link:hover .pc-micon,
.pc-sidebar .pc-navbar > .pc-item.active > .pc-link .pc-micon,
.pc-sidebar .pc-navbar > .pc-item.pc-hasmenu.pc-trigger > .pc-link .pc-micon {
    background: rgba(255, 255, 255, .2);
    color: #fff;
}

.pc-sidebar .pc-item .pc-arrow { color: var(--nav-muted); }
.pc-sidebar .pc-navbar > .pc-item > .pc-link:hover .pc-arrow,
.pc-sidebar .pc-navbar > .pc-item.pc-hasmenu.pc-trigger > .pc-link .pc-arrow { color: #fff; }

.pc-sidebar .pc-submenu { padding-left: 30px; }
.pc-sidebar .pc-submenu .pc-item .pc-link {
    font-weight: 600;
    font-size: .88rem;
    color: var(--nav-muted);
    padding: 9px 12px;
    background: transparent !important;
}
.pc-sidebar .pc-submenu .pc-item .pc-link:hover,
.pc-sidebar .pc-submenu .pc-item.active .pc-link {
    background: var(--nav-chip) !important;
    color: var(--nav-primary) !important;
}

.pc-header .pc-mob-drp .pc-head-link {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(37, 99, 235, .10);
    color: #2563eb;
}

[data-pc-theme="dark"] .pc-header .pc-mob-drp .pc-head-link {
    background: rgba(96, 165, 250, .14);
    color: #60a5fa;
}

.pc-header .dropdown-user-profile {
    border: 1px solid rgba(148, 163, 184, .20) !important;
    border-radius: 20px !important;
    box-shadow: 0 20px 50px rgba(15, 23, 42, .18) !important;
    background: #ffffff;
    overflow: hidden;
    margin-top: 8px !important;
}

.pc-header .dropdown-user-profile .dropdown-body { padding: 18px; }

[data-pc-theme="dark"] .pc-header .dropdown-user-profile {
    background: #151f2e;
    border-color: rgba(148, 163, 184, .16) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .45) !important;
}

@media (max-width: 575.98px) {
    .pc-header .dropdown-user-profile {
        right: 8px !important;
        min-width: 0 !important;
        width: calc(100vw - 16px) !important;
    }
}

/* Support Button */
.support-button { position: fixed; bottom: 25px; right: 25px; z-index: 9999; display: flex; flex-direction: column; align-items: flex-end; }
.support-main-btn { background: rgba(13, 110, 253, 0.85); backdrop-filter: blur(8px); border: 1px solid rgba(255, 255, 255, 0.4); width: 60px; height: 60px; border-radius: 50%; box-shadow: 0 8px 32px rgba(13, 110, 253, 0.4); cursor: pointer; color: white; font-size: 28px; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; }
.support-main-btn:hover { transform: scale(1.08) translateY(-3px); box-shadow: 0 12px 40px rgba(13, 110, 253, 0.6); }
.support-options { display: flex; flex-direction: column; margin-bottom: 15px; opacity: 0; visibility: hidden; transform: translateY(20px); transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55); }
.support-options.show { opacity: 1; visibility: visible; transform: translateY(0); }
.support-link { background: rgba(255, 255, 255, 0.7); backdrop-filter: blur(8px); border: 1px solid rgba(255, 255, 255, 0.9); border-radius: 50%; width: 50px; height: 50px; margin-bottom: 12px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; font-size: 22px; text-decoration: none; }
.support-link:hover { transform: scale(1.15) translateY(-3px); background: rgba(255, 255, 255, 0.95); }

/* Dark Mode Overrides */
[data-pc-theme="dark"] .desktop-navbar-wrapper, [data-pc-theme="dark"] .modern-dropdown, [data-pc-theme="dark"] .pc-header, [data-pc-theme="dark"] .pc-sidebar, [data-pc-theme="dark"] .pc-sidebar .navbar-wrapper {
    background: rgba(22, 28, 36, 0.65) !important; border: 1px solid rgba(255, 255, 255, 0.05) !important; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5) !important;
}
[data-pc-theme="dark"] .desktop-navbar-wrapper, [data-pc-theme="dark"] .modern-dropdown { border-top: 1px solid rgba(255, 255, 255, 0.12) !important; }
[data-pc-theme="dark"] .modern-link { color: #94a3b8; }
[data-pc-theme="dark"] .modern-link:hover, [data-pc-theme="dark"] .modern-link.active { background: rgba(13, 110, 253, 0.15); color: #fff !important; }
[data-pc-theme="dark"] .dropdown-link { color: #cbd5e1; }
[data-pc-theme="dark"] .dropdown-link:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
[data-pc-theme="dark"] .dropdown-divider { border-color: rgba(255, 255, 255, 0.05); }
[data-pc-theme="dark"] .theme-btn { background: rgba(0, 0, 0, 0.3); border-color: rgba(255, 255, 255, 0.08); color: #e2e8f0; }
[data-pc-theme="dark"] .theme-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
[data-pc-theme="dark"] .support-main-btn { background: rgba(13, 110, 253, 0.5); border-color: rgba(255, 255, 255, 0.1); }
[data-pc-theme="dark"] .support-link { background: rgba(22, 28, 36, 0.7); border-color: rgba(255, 255, 255, 0.08); }
[data-pc-theme="dark"] .support-link:hover { background: rgba(22, 28, 36, 0.9); }

/* ===================== MẪU 6: GLASSMORPHISM TOAST ===================== */
.glass-toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    max-width: calc(100vw - 48px);
}

.glass-toast {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    padding: 16px;
    border-radius: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    width: 350px;
    max-width: 100%;
    box-sizing: border-box;
}

.glass-toast-icon {
    font-size: 24px;
    margin-top: 2px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.05);
    flex-shrink: 0;
    color: #10b981; /* Xanh lá */
}

.glass-toast-content {
    flex: 1;
    min-width: 0;
    line-height: 1.4;
}

.glass-toast-title {
    margin: 0 0 4px 0;
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
}

.glass-toast-message {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
}

.glass-toast-close {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 0;
    margin-top: 2px;
    font-size: 16px;
    transition: color 0.2s;
    flex-shrink: 0;
    z-index: 10;
}

.glass-toast-close:hover { color: #0f172a; }

.glass-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: rgba(0,0,0,0.1);
    animation: progressGlass 4.5s linear forwards;
}

.toast-enter { animation: slideInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.toast-leave { animation: fadeOutRight 0.4s ease-in forwards; }

@keyframes slideInRight { 0% { transform: translateX(120%); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }
@keyframes fadeOutRight { 0% { transform: translateX(0); opacity: 1; height: auto; margin-bottom: 12px; } 100% { transform: translateX(120%); opacity: 0; height: 0; margin-bottom: 0; padding: 0; overflow: hidden; border: none; } }
@keyframes progressGlass { 0% { width: 100%; } 100% { width: 0%; } }

/* Dark Mode Glass Toast */
[data-pc-theme="dark"] .glass-toast {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
[data-pc-theme="dark"] .glass-toast-title { color: #f8fafc; }
[data-pc-theme="dark"] .glass-toast-message { color: #94a3b8; }
[data-pc-theme="dark"] .glass-toast-close { color: #94a3b8; }
[data-pc-theme="dark"] .glass-toast-close:hover { color: #fff; }
[data-pc-theme="dark"] .glass-toast-progress { background: rgba(255,255,255,0.2); }

@media (max-width: 575.98px) {
    .glass-toast-container { top: 16px; right: 16px; left: 16px; max-width: calc(100vw - 32px); }
    .glass-toast { width: 100%; }
}
