﻿/* ===============================
   APP LAYOUT - SAPULICO CLEAN UI
   Replace toàn bộ file app-layout.css
   =============================== */

:root {
    --layout-primary: #168fbd;
    --layout-primary-2: #22a4cf;
    --layout-primary-dark: #0f6f9d;
    --layout-dark: #12395f;
    --layout-text: #214b73;
    --layout-muted: #718ca6;
    --layout-bg: #f3f9fd;
    --layout-card: #ffffff;
    --layout-border: #dcebf4;
    --layout-danger: #e24a4a;
    --sidebar-width: 264px;
    --topbar-height: 70px;
    --shadow-soft: 0 8px 22px rgba(25, 77, 124, 0.06);
    --shadow-card: 0 12px 30px rgba(25, 77, 124, 0.09);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    background: var(--layout-bg);
    color: var(--layout-dark);
}

body {
    line-height: 1.45;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
}

/* ===============================
   MAIN LAYOUT
   =============================== */

.app-layout {
    min-height: 100vh;
    display: flex;
    background: radial-gradient(circle at top left, rgba(34, 164, 207, 0.10), transparent 32%), linear-gradient(180deg, #f8fcff 0%, #eef7fc 100%);
}

.app-main-area {
    flex: 1;
    min-width: 0;
}

/* ===============================
   DESKTOP SIDEBAR
   =============================== */

.desktop-sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: sticky;
    top: 0;
    align-self: flex-start;
    padding: 18px 12px;
    background: rgba(255, 255, 255, 0.94);
    border-right: 1px solid rgba(220, 235, 244, 0.95);
    backdrop-filter: blur(18px);
    display: flex;
    flex-direction: column;
    z-index: 40;
    overflow-y: auto;
}

    /* Scrollbar */
    .desktop-sidebar::-webkit-scrollbar,
    .sidebar-menu::-webkit-scrollbar,
    .mobile-drawer-menu::-webkit-scrollbar {
        width: 6px;
    }

    .desktop-sidebar::-webkit-scrollbar-thumb,
    .sidebar-menu::-webkit-scrollbar-thumb,
    .mobile-drawer-menu::-webkit-scrollbar-thumb {
        background: #cfe1ee;
        border-radius: 999px;
    }

/* Brand */
.sidebar-brand {
    flex: 0 0 auto;
    min-height: 72px;
    padding: 8px 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--layout-primary-2), var(--layout-primary-dark));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 12px 26px rgba(22, 143, 189, 0.24);
    flex: 0 0 auto;
}

.company-logo {
    background: transparent;
    box-shadow: none;
    padding: 0;
    overflow: hidden;
}

    .company-logo img {
        width: 52px;
        height: 52px;
        object-fit: contain;
        display: block;
    }

.sidebar-title {
    color: var(--layout-dark);
    font-size: 20px;
    line-height: 1.05;
    font-weight: 900;
    letter-spacing: -0.04em;
}

.sidebar-subtitle {
    margin-top: 4px;
    color: var(--layout-muted);
    font-size: 13px;
    font-weight: 700;
}

/* Menu */
.sidebar-menu {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
}

.sidebar-bottom {
    flex: 0 0 auto;
    margin-top: 6px;
    padding-top: 0;
    border-top: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-link {
    min-height: 46px;
    padding: 0 13px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--layout-text);
    font-size: 14px;
    font-weight: 800;
    position: relative;
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

    .sidebar-link:hover {
        background: #f2f9fd;
        color: var(--layout-primary);
    }

    .sidebar-link.active {
        background: #eaf7fc;
        color: var(--layout-primary);
    }

        .sidebar-link.active::before {
            content: "";
            position: absolute;
            left: 6px;
            top: 12px;
            bottom: 12px;
            width: 4px;
            border-radius: 999px;
            background: var(--layout-primary);
        }

    /* Direct icon, dùng cho nút Đăng xuất desktop */
    .sidebar-link > i {
        width: 30px;
        height: 30px;
        min-width: 30px;
        border-radius: 12px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: #7c96ad;
        font-size: 15px;
        transition: 0.18s ease;
    }

    .sidebar-link:hover > i {
        color: var(--layout-primary);
    }

    .sidebar-link.logout > i {
        background: #fff0f0;
        color: #ef4444;
    }

/* ===============================
   MENU ICON BOX
   =============================== */

.menu-icon-box {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    line-height: 1;
    flex: 0 0 auto;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
    transition: transform 0.18s ease;
}

    .menu-icon-box i {
        width: auto;
        min-width: 0;
        height: auto;
        color: currentColor;
        font-size: 15px;
        line-height: 1;
    }

.sidebar-link:hover .menu-icon-box,
.drawer-link:hover .menu-icon-box {
    transform: translateY(-1px);
}

.sidebar-link.active .menu-icon-box,
.drawer-link.active .menu-icon-box {
    transform: scale(1.02);
}

.menu-icon-text {
    font-size: 17px;
    font-weight: 900;
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
}

/* Icon colors */
.icon-home {
    background: #e7f7fc;
    color: #168fbd;
}

.icon-orange {
    background: #fff3e8;
    color: #f29a2e;
}

.icon-green {
    background: #e9f8ef;
    color: #2fa85a;
}

.icon-purple {
    background: #f1ecff;
    color: #7755d9;
}

.icon-blue {
    background: #eaf4ff;
    color: #2f8df2;
}

.icon-cyan {
    background: #e8fbff;
    color: #0ea5b7;
}

.icon-yellow {
    background: #fff8df;
    color: #d5a019;
}

.icon-brown {
    background: #f9efe6;
    color: #b77334;
}

.icon-gray {
    background: #eef4f8;
    color: #7c96ad;
}

.icon-red {
    background: #fff0f0;
    color: #ef4444;
}

.logout {
    color: var(--layout-danger);
}

    .logout .menu-icon-box,
    .logout .menu-icon-box i {
        color: #ef4444;
    }

/* ===============================
   OPTIONAL COLLAPSE MENU
   Nếu sau này anh dùng nhóm xổ xuống
   =============================== */

.sidebar-group,
.drawer-group {
    margin: 0;
    padding: 6px;
    border-radius: 18px;
    background: #f8fcff;
    border: 1px solid #e6f0f6;
}

.sidebar-collapse-toggle,
.drawer-collapse-toggle {
    width: 100%;
    min-height: 46px;
    padding: 0 13px;
    border: none;
    outline: none;
    border-radius: 15px;
    background: transparent;
    cursor: pointer;
}

.sidebar-group-title,
.drawer-group-title {
    color: var(--layout-dark);
    font-size: 14px;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-submenu,
.drawer-submenu {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.24s ease, opacity 0.18s ease, margin-top 0.18s ease;
}

.sidebar-collapse-group.open .sidebar-submenu,
.drawer-collapse-group.open .drawer-submenu {
    max-height: 120px;
    opacity: 1;
    margin-top: 5px;
}

.sidebar-sublink,
.drawer-sublink {
    min-height: 40px;
    padding: 0 12px 0 46px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    color: #557592;
    font-size: 13px;
    font-weight: 800;
    transition: 0.18s ease;
}

    .sidebar-sublink + .sidebar-sublink,
    .drawer-sublink + .drawer-sublink {
        margin-top: 4px;
    }

    .sidebar-sublink:hover,
    .drawer-sublink:hover,
    .sidebar-sublink.active,
    .drawer-sublink.active {
        background: #eef8fd;
        color: var(--layout-primary);
    }

.collapse-arrow {
    margin-left: auto;
    font-size: 12px;
    color: #8aa2b7;
    transition: transform 0.22s ease, color 0.18s ease;
}

.sidebar-collapse-group.open .collapse-arrow,
.drawer-collapse-group.open .collapse-arrow {
    transform: rotate(180deg);
    color: var(--layout-primary);
}

/* ===============================
   TOPBAR
   =============================== */

.app-topbar {
    height: var(--topbar-height);
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 35;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: rgba(255, 255, 255, 0.86);
    border-bottom: 1px solid rgba(220, 235, 244, 0.92);
    backdrop-filter: blur(18px);
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 13px;
}

.topbar-left {
    min-width: 0;
}

.topbar-right {
    flex: 0 0 auto;
}

.topbar-menu-btn {
    width: 42px;
    height: 42px;
    border: 1px solid var(--layout-border);
    border-radius: 15px;
    background: #ffffff;
    color: #28567e;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-soft);
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

    .topbar-menu-btn:hover {
        color: var(--layout-primary);
        background: #f6fbfe;
        transform: translateY(-1px);
    }

.topbar-title {
    color: var(--layout-dark);
    font-size: 22px;
    line-height: 1.1;
    font-weight: 900;
    letter-spacing: -0.04em;
    white-space: nowrap;
}

.topbar-subtitle {
    margin-top: 4px;
    color: var(--layout-muted);
    font-size: 13px;
    font-weight: 600;
}

.title-mobile {
    display: none;
}

.title-desktop {
    display: inline;
}

/* Notification */
.topbar-notify {
    width: 42px;
    height: 42px;
    border: 1px solid var(--layout-border);
    border-radius: 15px;
    background: #ffffff;
    color: #28567e;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-soft);
    transition: 0.18s ease;
}

    .topbar-notify:hover {
        color: var(--layout-primary);
        background: #f6fbfe;
    }

    .topbar-notify span {
        position: absolute;
        top: 9px;
        right: 10px;
        width: 8px;
        height: 8px;
        border-radius: 999px;
        background: #ff4d5e;
        border: 2px solid #ffffff;
    }

/* User */
.topbar-user {
    height: 46px;
    padding: 5px 12px 5px 6px;
    border: 1px solid var(--layout-border);
    border-radius: 999px;
    background: #ffffff;
    display: flex;
    align-items: center;
    gap: 9px;
    box-shadow: var(--shadow-soft);
}

.topbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, var(--layout-primary-2), var(--layout-primary-dark));
    color: #ffffff;
    font-size: 15px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
}
    .topbar-avatar span {
        width: 100%;
        height: 100%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

.topbar-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.topbar-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

    .topbar-user-info strong {
        color: #173f67;
        font-size: 13px;
        font-weight: 800;
    }

    .topbar-user-info span {
        margin-top: 3px;
        color: #7d98af;
        font-size: 11px;
        font-weight: 600;
    }

/* ===============================
   PAGE CONTENT
   =============================== */

.app-page-content {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 22px 24px;
}

/* ===============================
   MOBILE DRAWER
   =============================== */

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(16, 36, 58, 0.42);
    opacity: 0;
    visibility: hidden;
    transition: 0.25s ease;
    z-index: 80;
}

    .drawer-overlay.show {
        opacity: 1;
        visibility: visible;
    }

.mobile-drawer {
    position: fixed;
    top: 0;
    left: -360px;
    width: 330px;
    max-width: 86vw;
    height: 100dvh;
    background: #ffffff;
    z-index: 2000;
    box-shadow: 18px 0 40px rgba(20, 49, 84, 0.16);
    transition: left 0.28s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

    .mobile-drawer.show {
        left: 0;
    }

.drawer-open {
    overflow: hidden;
}

.mobile-drawer-header {
    flex: 0 0 auto;
    min-height: 82px;
    padding: 16px 18px;
    border-bottom: 1px solid #e8eff5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.mobile-drawer-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.mobile-drawer-logo {
    width: 48px;
    height: 48px;
    border-radius: 17px;
    background: linear-gradient(135deg, var(--layout-primary-2), var(--layout-primary-dark));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex: 0 0 auto;
    box-shadow: 0 10px 22px rgba(22, 143, 189, 0.22);
}

.company-mobile-logo {
    background: transparent;
    box-shadow: none;
    padding: 0;
    overflow: hidden;
}

    .company-mobile-logo img {
        width: 48px;
        height: 48px;
        object-fit: contain;
        display: block;
    }

.mobile-drawer-brand strong,
.mobile-drawer-brand span {
    display: block;
}

.mobile-drawer-brand strong {
    color: var(--layout-dark);
    font-size: 18px;
    line-height: 1.1;
    font-weight: 900;
}

.mobile-drawer-brand span {
    margin-top: 3px;
    color: var(--layout-muted);
    font-size: 13px;
    font-weight: 700;
}

.mobile-drawer-menu {
    flex: 1 1 auto;
    min-height: 0;
    padding: 14px 12px 18px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.drawer-link {
    min-height: 46px;
    padding: 0 13px;
    border-radius: 15px;
    color: var(--layout-text);
    font-size: 14px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background-color 0.18s ease, color 0.18s ease;
}

    .drawer-link:hover {
        background: #f2f8fc;
        color: var(--layout-primary);
    }

    .drawer-link.active {
        background: #eaf7fc;
        color: var(--layout-primary);
    }

.drawer-bottom {
    margin-top: 5px;
    padding-top: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ===============================
   DESKTOP / TABLET / MOBILE
   =============================== */

@media (min-width: 992px) {
    .topbar-menu-btn#openDrawer {
        display: none;
    }
}

@media (max-width: 991px) {
    .desktop-sidebar {
        display: none;
    }

    .app-layout {
        display: block;
    }

    .app-page-content {
        max-width: none;
        padding: 18px 16px 38px;
    }
}

@media (max-width: 575px) {
    .app-layout {
        min-height: 100svh;
        background: #f3f9fd;
    }

    .app-topbar {
        height: 62px;
        padding: 0 14px;
        background: rgba(255, 255, 255, 0.94);
    }

    .topbar-left {
        gap: 10px;
    }

    .topbar-right {
        gap: 8px;
    }

    .topbar-menu-btn {
        width: 38px;
        height: 38px;
        border-radius: 13px;
        flex: 0 0 auto;
    }

    .title-desktop {
        display: none;
    }

    .title-mobile {
        display: inline;
    }

    .topbar-title {
        font-size: 21px;
        max-width: calc(100vw - 120px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar-subtitle {
        display: none;
    }

    .topbar-notify {
        display: none;
    }

    .topbar-user {
        width: 38px;
        height: 38px;
        padding: 0;
        justify-content: center;
        flex: 0 0 auto;
    }

    .topbar-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .topbar-user-info {
        display: none;
    }

    .app-page-content {
        padding: 14px 14px 24px;
    }

    .mobile-drawer {
        width: 84vw;
    }

    .mobile-drawer-header {
        min-height: 80px;
        padding: 16px;
    }

    .mobile-drawer-logo,
    .company-mobile-logo img {
        width: 46px;
        height: 46px;
    }

    .drawer-link {
        min-height: 46px;
        font-size: 14px;
        border-radius: 15px;
    }

    .menu-icon-box {
        width: 30px;
        height: 30px;
        min-width: 30px;
        border-radius: 11px;
        font-size: 15px;
    }

        .menu-icon-box i {
            font-size: 15px;
        }
}
/* =========================================================
   FIX LAYOUT LUÔN NẰM TRÊN MAP
   ========================================================= */

.app-layout {
    position: relative;
    z-index: 1;
    isolation: isolate;
}

.desktop-sidebar {
    position: relative;
    z-index: 3000 !important;
    background: #ffffff;
}

.app-main-area {
    position: relative;
    z-index: 1;
    min-width: 0;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 2800 !important;
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.app-page-content {
    position: relative;
    z-index: 1;
    overflow: hidden;
}

/* Mobile drawer phải cao hơn map */
.drawer-overlay {
    z-index: 5000 !important;
}

.mobile-drawer {
    z-index: 5100 !important;
}
/* =========================================================
   SHAT QUIZ TRÊN NAVBAR / LAYOUT TOPBAR
   ========================================================= */

.topbar-shat-slot {
    display: none;
}

.shat-exam-body .topbar-shat-slot {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.shat-exam-body .topbar-left > div {
    display: none;
}

.topbar-shat-compact {
    width: min(520px, 100%);
    padding: 8px 12px;
    border-radius: 18px;
    background: linear-gradient(135deg, #0f8fc7, #2563eb);
    color: #ffffff;
    box-shadow: 0 12px 26px rgba(37, 99, 235, .18);
}

.topbar-shat-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.topbar-shat-title {
    min-width: 0;
}

    .topbar-shat-title span {
        display: block;
        font-size: 11px;
        font-weight: 850;
        line-height: 1.1;
        opacity: .9;
    }

    .topbar-shat-title strong {
        display: block;
        margin-top: 2px;
        font-size: 18px;
        font-weight: 950;
        line-height: 1.1;
        white-space: nowrap;
    }

.topbar-shat-timer {
    height: 34px;
    padding: 0 11px;
    border-radius: 13px;
    background: rgba(255,255,255,.17);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    flex: 0 0 auto;
}

    .topbar-shat-timer i {
        font-size: 13px;
    }

    .topbar-shat-timer strong {
        font-size: 15px;
        font-weight: 950;
    }

.topbar-shat-progress {
    height: 5px;
    margin-top: 7px;
    border-radius: 999px;
    background: rgba(255,255,255,.24);
    overflow: hidden;
}

    .topbar-shat-progress div {
        height: 100%;
        border-radius: 999px;
        background: #ffffff;
    }

.topbar-shat-foot {
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

    .topbar-shat-foot span,
    .topbar-shat-foot small {
        color: rgba(255,255,255,.92);
        font-size: 10.5px;
        font-weight: 850;
        line-height: 1.1;
    }

    .topbar-shat-foot .shat-save-status.saving {
        color: #fff7ed;
    }

    .topbar-shat-foot .shat-save-status.saved {
        color: #dcfce7;
    }

    .topbar-shat-foot .shat-save-status.error {
        color: #fee2e2;
    }

/* Mobile: navbar thành 3 cột: menu - quiz - avatar */
@media (max-width: 575px) {
    .shat-exam-body .app-topbar {
        height: auto;
        min-height: 82px;
        padding: 8px 10px;
        display: grid;
        grid-template-columns: 40px minmax(0, 1fr) 40px;
        align-items: center;
        gap: 8px;
    }

    .shat-exam-body .topbar-left {
        min-width: 0;
        gap: 0;
    }

    .shat-exam-body .topbar-menu-btn {
        width: 38px;
        height: 38px;
        border-radius: 14px;
    }

    .shat-exam-body .topbar-right {
        min-width: 0;
        justify-content: flex-end;
        gap: 0;
    }

    .shat-exam-body .topbar-notify {
        display: none;
    }

    .shat-exam-body .topbar-user {
        width: 38px;
        height: 38px;
        padding: 0;
        flex: 0 0 38px;
    }

    .shat-exam-body .topbar-avatar {
        width: 32px;
        height: 32px;
        flex: 0 0 32px;
    }

    .shat-exam-body .topbar-shat-slot {
        width: 100%;
    }

    .topbar-shat-compact {
        width: 100%;
        padding: 8px 10px;
        border-radius: 17px;
        box-shadow: 0 10px 22px rgba(37, 99, 235, .16);
    }

    .topbar-shat-title span {
        font-size: 10.5px;
    }

    .topbar-shat-title strong {
        font-size: 17px;
    }

    .topbar-shat-timer {
        height: 32px;
        padding: 0 9px;
        border-radius: 12px;
    }

        .topbar-shat-timer strong {
            font-size: 14px;
        }

    .topbar-shat-progress {
        height: 5px;
        margin-top: 6px;
    }

    .topbar-shat-foot span,
    .topbar-shat-foot small {
        font-size: 10px;
    }
}
/* Bỏ dòng chữ nhỏ "Kiểm tra SHAT", căn lại câu hiện tại */
.topbar-shat-title strong {
    margin-top: 0 !important;
    font-size: 19px;
}

@media (max-width: 575px) {
    .topbar-shat-title strong {
        font-size: 18px;
    }

    .topbar-shat-main {
        align-items: center;
    }
}
