/* trc-layout.css — khung app dùng chung mọi vai (topbar/sidebar/app-shell).
   Tách ra từ <style> nhúng thẳng trong Views/Shared/_Layout.cshtml (12/09/2026)
   để dễ bảo trì — nội dung y hệt bản cũ (chỉ bỏ #secondary-nav/.sec-nav-link đã
   xác nhận mồ côi, và đổi @@media Razor-escape thành @media CSS thuần). */
:root {
    --sidebar-w: 200px;
    --sidebar-collapsed-w: 56px;
    --topbar-h: 56px;
    /* 26/09/2026 (Phase 3.1): bỏ 10 biến trùng tên trc-brand.css (--transition, --primary*, --bg, --card,
       --text, --text-muted, --border, --app-max-w) — file này nạp SAU nên từng đè màu brand trên 66 trang.
       Nguồn duy nhất giờ là trc-brand.css (--app-max-w 1500px đã chuyển sang đó). */
    --app-radius: 18px;
}

html, body {
    height: 100%;
    margin: 0;
    color: var(--text);
}

body {
    /* Trước đây khai "Inter" nhưng KHÔNG hề có @font-face hay link tải font
       nào trong dự án — chữ luôn rơi về font hệ thống. Nay dùng đúng token
       để font là một chỗ khai duy nhất (xem css/trc-brand.css). */
    font-family: var(--trc-font-ui);
    font-size: 13.5px;
    /* ── ẢNH NỀN: thay link bên dưới bằng ảnh cỏ lau của bạn ── */
    background: var(--app-backdrop);
    background: linear-gradient(34deg, rgba(171, 219, 196, 0.56) 0%, rgba(87, 199, 133, 0.52) 100%);
    min-height: 100vh;
}

/* ── KHUNG APP DẠNG "CARD" BAO TRỌN TOÀN BỘ WEB ── */
#app-shell {
    position: relative;
    margin: 18px 18px;
    min-height: calc(100vh - 36px);
    background: var(--card);
    border-radius: var(--app-radius);
    box-shadow: 0 10px 40px rgba(16, 24, 25, .08), 0 2px 8px rgba(16,24,25,.04);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── TOPBAR ── */
#layout-topbar {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-h);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 18px;
    gap: 12px;
    z-index: 1000;
    flex-shrink: 0;
}

#sidebar-toggle {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: .15s;
    flex-shrink: 0;
}

    #sidebar-toggle:hover {
        background: var(--primary-light);
        color: var(--primary-dark);
    }

.brand-logo {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    box-shadow: 0 0 0 1.5px var(--trc-green-soft);
}

.brand {
    font-family: var(--trc-font-display, inherit);
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -.01em;
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

    .brand:hover {
        color: var(--primary-dark);
    }

#topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 17/10/2026 (Mốc 2 – NEN): thay các style="" tĩnh trong _Layout (tên người dùng, link Đổi mật khẩu / Đăng nhập / Đăng xuất, form). */
.topbar-user { font-size: 13px; color: var(--text-muted); }

.topbar-form { margin: 0; }

.topbar-link {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 24px;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    white-space: nowrap;
}

    .topbar-link:hover { color: var(--trc-green-deep); text-decoration: underline; }

.topbar-link--btn { background: none; border: none; cursor: pointer; padding: 0; font-family: inherit; }

/* M3-PERF 18/10/2026: biểu tượng SVG thay phông bootstrap-icons cho trang khách (cùng cỡ/căn dòng với .bi: 1em, hạ -.125em). */
.bi-inline { width: 1em; height: 1em; fill: currentColor; vertical-align: -.125em; flex-shrink: 0; }

/* Màn hẹp: giữ lại biểu tượng chìa khoá, giấu chữ "Đổi mật khẩu" cho đỡ chật */
@media (max-width: 640px) {
    .pw-link-label { display: none; }
}

/* 17/10/2026 (Mốc 2): máy rất hẹp — bỏ mã người dùng (vẫn còn huy hiệu vai) để nút "Đăng xuất" không bị bẻ dòng. */
@media (max-width: 480px) {
    .topbar-user { display: none; }
}

/* ── ROLE BADGES ── */
.role-badge {
    font-size: 12px; /* 17/10/2026 (Mốc 2): từ 10.5px — chữ nhỏ nhất 12px */
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.role-admin {
    background: var(--tone-purple-bg);
    color: var(--tone-purple-text);
}

.role-coach {
    background: var(--trc-green-soft);
    color: var(--trc-green-deep);
}

.role-student {
    background: var(--trc-green-soft);
    color: var(--trc-green-deep);
}

.role-parent {
    background: var(--tone-lime-bg);
    color: var(--tone-lime-text);
}

/* ── BODY ROW (sidebar + content) ── */
#app-body-row {
    position: relative;
    flex: 1;
    display: flex;
    min-height: 0;
}

/* ── SIDEBAR ── */
#sidebar {
    position: relative;
    flex-shrink: 0;
    width: var(--sidebar-w);
    background: var(--surface-2);
    border-right: 1px solid var(--border);
    overflow-x: hidden;
    overflow-y: auto;
    transition: width var(--transition), transform var(--transition);
    z-index: 900;
    display: flex;
    flex-direction: column;
}

    #sidebar.collapsed {
        width: var(--sidebar-collapsed-w);
    }

.sidebar-body {
    flex: 1;
    padding: 8px 0;
}

.nav-section {
    padding: 13px 16px 4px;
    font-size: 12px; /* 17/10/2026 (Mốc 2): từ 10px */
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .06em;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity .15s, height .15s, padding .15s;
}

#sidebar.collapsed .nav-section {
    opacity: 0;
    height: 0;
    padding: 0;
    overflow: hidden;
}

.nav-divider {
    border-top: 1px solid var(--surface-3);
    margin: 6px 10px;
}

.nav-link-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 38px;
    margin: 2px 8px;
    padding: 0 12px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--tone-gray-text);
    font-size: 13px;
    font-weight: 500;
    transition: .15s;
    white-space: nowrap;
}

    .nav-link-item i {
        font-size: 17px;
        flex-shrink: 0;
    }

    .nav-link-item:hover {
        background: var(--primary-light);
        color: var(--primary-dark);
    }

    .nav-link-item.active {
        background: var(--primary);
        color: var(--text-inverse);
        font-weight: 600;
    }

        .nav-link-item.active::before {
            content: "";
            position: absolute;
            left: -8px;
            top: 6px;
            bottom: 6px;
            width: 3px;
            border-radius: 999px;
            background: var(--primary-dark);
        }

.nav-label {
    transition: opacity .15s, width .15s;
    overflow: hidden;
    white-space: nowrap;
}

/* Huy hiệu số việc đang chờ duyệt (Alt Pool / Đề xuất xóa bài) */
.nav-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--danger);
    color: var(--text-inverse);
    font-size: 12px; /* 17/10/2026 (Mốc 2): từ 11px */
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    flex: none;
}

#sidebar.collapsed .nav-badge {
    position: absolute;
    top: 4px;
    right: 6px;
    margin-left: 0;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    padding: 0 4px;
    font-size: 12px;
}

#sidebar.collapsed .nav-label {
    opacity: 0;
    width: 0;
}

/* Tooltip when collapsed */
#sidebar.collapsed .nav-link-item {
    justify-content: center;
    padding: 0;
}

    #sidebar.collapsed .nav-link-item::after {
        content: attr(data-label);
        position: absolute;
        left: 64px;
        background: var(--text-primary);
        color: var(--text-inverse);
        padding: 5px 10px;
        border-radius: 7px;
        font-size: 12px;
        white-space: nowrap;
        pointer-events: none;
        opacity: 0;
        transition: opacity .1s;
        z-index: 1200;
    }

    #sidebar.collapsed .nav-link-item:hover::after,
    #sidebar.collapsed .nav-link-item:focus-visible::after {
        opacity: 1;
    }

/* ── MOBILE OVERLAY BACKDROP ── */
#sidebar-backdrop {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 899;
    opacity: 0;
    transition: opacity .22s ease;
}

    #sidebar-backdrop.visible {
        opacity: 1;
    }

/* ── MAIN CONTENT ── */
#main-content {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
}

    /* WEB-01 17/10/2026: <main tabindex="-1"> nhận focus khi bấm "Bỏ qua menu" — không vẽ viền quanh cả vùng nội dung. */
    #main-content:focus { outline: none; }

/* WEB-01 17/10/2026: "Bỏ qua menu, tới nội dung chính" — ẩn ngoài màn hình, hiện ở góc trên trái khi có focus bàn phím.
   Chữ kem trên xanh đậm 7,93:1 (check-contrast.mjs --trc-cream --trc-green-deep). */
.trc-skip-link {
    position: absolute;
    left: var(--sp-3);
    top: -4rem;
    z-index: 2000;
    padding: var(--sp-2) var(--sp-4);
    background: var(--trc-green-deep);
    color: var(--trc-cream);
    border-radius: var(--radius-md);
    font-weight: 600;
    text-decoration: none;
    min-height: 44px; /* 17/10/2026 (Mốc 2): vùng bấm 44px (trước 34px) */
    display: inline-flex;
    align-items: center;
}

    .trc-skip-link:focus,
    .trc-skip-link:focus-visible {
        top: var(--sp-3);
        color: var(--trc-cream);
        outline: 2px solid var(--trc-cream);
        outline-offset: -4px;
    }

.content-inner {
    padding: 24px;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 999px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--text-muted);
    }

/* ── MOBILE ── */
@media (max-width: 768px) {
    #app-shell {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
    }
    /* Sidebar ẩn ra ngoài thay vì thu nhỏ về 0 */
    #sidebar,
    #sidebar.collapsed {
        width: var(--sidebar-w) !important;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        transform: translateX(-100%);
        box-shadow: 0 0 0 9999px transparent;
    }
        /* Khi mở (class mobile-open) thì trượt vào */
        #sidebar.mobile-open {
            transform: translateX(0) !important;
        }

    /* 17/10/2026 (Mốc 2 – NEN): menu đóng chỉ dịch ra ngoài màn hình — các liên kết trong đó VẪN nhận Tab (tiêu điểm "biến mất").
       visibility: hidden gỡ chúng khỏi thứ tự Tab và cây truy cập; trễ đúng thời gian trượt để hoạt ảnh đóng vẫn thấy. */
    #sidebar { visibility: hidden; transition: transform var(--transition), visibility 0s linear .18s; }
    #sidebar.mobile-open { visibility: visible; transition: transform var(--transition), visibility 0s; }

    .content-inner {
        padding: 16px;
    }
}

/* ── Dải báo "đang xem thử vai khác" ── */
.viewas-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 8px 18px;
    background: var(--trc-yellow);
    color: var(--trc-green-deep);
    font-size: 13px;
    font-weight: 600;
    border-bottom: 2px solid var(--trc-green-deep);
}

.viewas-back {
    border: 1px solid var(--trc-green-deep);
    background: var(--trc-green-deep);
    color: var(--text-inverse);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}

    .viewas-back:hover {
        filter: brightness(1.15);
    }

/* 17/10/2026 (Mốc 2): nút "Về lại Admin" cao 28px → 44px trên điện thoại/máy cảm ứng (WCAG 2.5.8 đòi ≥24px; ưu tiên 44px cho ngón tay). */
@media (max-width: 768px), (pointer: coarse) {
    .viewas-back { min-height: 44px; padding: 4px 16px; }
}

/* ── Nút + hộp "Góp ý" của tài khoản thử ──
   17/10/2026 (Mốc 2 – NEN): chuyển nguyên khối <style> nội tuyến từ _Layout.cshtml sang đây (nạp cho mọi trang có khung app).
   Hover nút dùng --trc-green-deep: chữ trắng trên --trc-green-bright chỉ 4,38:1 (<4,5 với chữ 12px đậm). */
.sfb-btn {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 900;
    background: var(--trc-green);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-pill);
    padding: 12px 18px;
    font-weight: 700;
    font-size: var(--fs-sm);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

    .sfb-btn:hover { background: var(--trc-green-deep); }

.sfb-field { margin-bottom: var(--sp-3); }

.sfb-mic {
    margin-top: 6px;
    border: none;
    background: var(--trc-green-soft);
    color: var(--trc-green-deep);
    border-radius: var(--radius-pill);
    padding: 6px 14px;
    font-size: var(--fs-sm);
    cursor: pointer;
}

    .sfb-mic[hidden] { display: none; }
    .sfb-mic.rec { background: var(--danger-bg); color: var(--danger-text); }

.sfb-shot-note { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 4px; }
