/* =========================================================
   QLHV CTUT - LAYOUT.CSS
   Chỉ chứa CSS layout: sidebar, topbar, footer, responsive shell.
   ========================================================= */

.app-shell {
    min-height: 100vh;
    display: flex;
    background: var(--bg);
}

.app-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    min-height: 100vh;
    background: linear-gradient(180deg, var(--primary-dark), var(--primary));
    color: #ffffff;
    position: sticky;
    top: 0;
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1040;
}

.brand-box {
    padding: 22px 20px 16px;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 14px;
    color: #ffffff;
    text-decoration: none;
}

.brand-link:hover {
    color: #ffffff;
}

.brand-logo {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 16px;
    background: linear-gradient(145deg, #ffffff, #dbeafe);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 20px;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.18);
}

.brand-text {
    min-width: 0;
}

.brand-name {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.brand-subtitle {
    margin-top: 4px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.74);
    line-height: 1.35;
}

.sidebar-system-info {
    margin: 0 16px 14px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.09);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.system-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.62);
    font-weight: 700;
}

.system-name {
    margin-top: 4px;
    font-size: 14px;
    line-height: 1.4;
    font-weight: 700;
}

.sidebar-menu {
    padding: 8px 12px;
    /* display: grid; */
    gap: 5px;
    flex: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 11px 14px;
    border-radius: 14px;
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.sidebar-link i {
    font-size: 18px;
    width: 22px;
    text-align: center;
    flex: 0 0 auto;
}

.sidebar-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
    transform: translateX(2px);
}

.sidebar-link.active {
    color: #10233b;
    background: #ffffff;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
}

.sidebar-link.active i {
    color: var(--primary);
}

.sidebar-link.disabled {
    opacity: .72;
    cursor: not-allowed;
}

.sidebar-footer {
    margin: 12px 16px 18px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer-title {
    font-size: 12px;
    font-weight: 800;
    line-height: 1.4;
}

.sidebar-footer-text {
    margin-top: 4px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.68);
    line-height: 1.45;
}

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    min-height: 84px;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    padding: 16px 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.page-heading {
    min-width: 0;
}

.btn-sidebar-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    background: #ffffff;
    border-radius: 13px;
    color: var(--primary);
    font-size: 22px;
    flex: 0 0 auto;
}

.page-eyebrow {
    font-size: 12px;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.page-title {
    margin: 4px 0 0;
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #f8fafc;
    flex: 0 0 auto;
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.user-info {
    min-width: 130px;
}

.user-name {
    font-size: 14px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}

.user-role {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

.btn-logout {
    margin-top: 2px;
    border: 0;
    background: transparent;
    color: var(--danger);
    padding: 0;
    font-size: 12px;
    font-weight: 700;
}

.btn-logout:hover {
    text-decoration: underline;
    color: #b91c1c;
}

.app-content {
    flex: 1;
    padding: 26px;
}

.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 26px;
    border-top: 1px solid var(--border);
    background: #ffffff;
    color: var(--muted);
    font-size: 13px;
}

.sidebar-backdrop {
    display: none;
}

/* Mobile: sidebar dạng trượt */
@media (max-width: 991.98px) {
    .app-shell {
        display: block;
    }

    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .app-main {
        width: 100%;
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.48);
        z-index: 1030;
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .btn-sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .app-topbar {
        padding: 14px 16px;
    }

    .app-content {
        padding: 18px 14px;
    }

    .app-footer {
        flex-direction: column;
        align-items: flex-start;
        padding: 14px 16px;
    }
}

@media (max-width: 575.98px) {
    .app-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-left,
    .topbar-user {
        width: 100%;
    }

    .topbar-user {
        justify-content: flex-start;
    }

    .page-title {
        font-size: 21px;
    }

    .brand-box {
        padding-top: 18px;
    }
}
