/* ==============================================================================
   HỆ THỐNG QUẢN LÝ ĐÀO TẠO VÀ CHỈ ĐẠO TUYẾN (TEF-CME) - BỆNH VIỆN K
   style.css - Thiết kế Layout 4 thành phần, Dark/Light Mode, Table & Modal
   ============================================================================== */

:root,
[data-bs-theme="light"] {
    --tef-primary: #007bff;
    --tef-primary-hover: #0069d9;
    --tef-switch-bg: #f1812e;
    --tef-overlay-bg: rgba(255, 255, 255, 0.75);
    --tef-sidebar-bg: #f8f9fa;
    --tef-sidebar-color: #333333;
    --tef-sidebar-hover: #e9ecef;
    --tef-header-bg: #ffffff;
    --tef-card-bg: #ffffff;
    --tef-border-color: #dee2e6;
    --tef-table-hover: rgba(0, 123, 255, 0.05);
}

[data-bs-theme="dark"] {
    color-scheme: dark;
    --tef-primary: #3d8bfd;
    --tef-primary-hover: #0d6efd;
    --tef-switch-bg: #f1812e;
    --tef-overlay-bg: rgba(30, 34, 39, 0.8);
    --tef-sidebar-bg: #1e2227;
    --tef-sidebar-color: #adb5bd;
    --tef-sidebar-hover: #2c313a;
    --tef-header-bg: #1e2227;
    --tef-card-bg: #212529;
    --tef-border-color: #373b3e;
    --tef-table-hover: rgba(255, 255, 255, 0.05);
}

/* Đồng bộ tự động các class nền sáng / chữ tối sang biến ngữ nghĩa khi bật Dark Mode */
[data-bs-theme="dark"] .bg-white {
    background-color: var(--bs-body-bg) !important;
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .bg-light,
[data-bs-theme="dark"] .text-bg-light {
    background-color: var(--bs-tertiary-bg) !important;
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .text-dark {
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .table-light > th,
[data-bs-theme="dark"] .table-light > td {
    --bs-table-bg: #2b3035;
    --bs-table-color: #dee2e6;
    --bs-table-border-color: #373b3e;
    background-color: #2b3035 !important;
    color: #dee2e6 !important;
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 0.875rem;
    margin: 0;
    padding: 0;
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    overflow: hidden;
    height: 100vh;
}

.wrapper {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* ==============================================================================
   1. SIDE MENU (SIDEBAR) & HEADER CON SIDE MENU
   ============================================================================== */
#sidebar {
    box-sizing: border-box;
    position: fixed;
    height: 100vh !important;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1020;
    width: 260px;
    background: var(--tef-sidebar-bg);
    border-right: 1px solid var(--bs-border-color);
    box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.sidebar-wrap {
    position: relative;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header con của Side Menu */
.sidebar-header {
    background-color: var(--tef-sidebar-bg);
    border-bottom: 1px solid var(--bs-border-color);
    display: flex;
    align-items: center;
    height: 3rem;
    padding: 0 0.75rem;
    overflow: hidden;
}

.sidebar-header .logo_square {
    height: 2.2rem;
    width: 44px;
    object-fit: contain;
    display: none;
    margin: 0 auto;
}

.sidebar-header .logo_name {
    height: 2.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
}

/* Khi sidebar thu gọn (.close) trên màn hình Desktop */
#sidebar.close {
    width: 60px;
}

#sidebar.close .sidebar-header {
    padding: 0;
    justify-content: center;
}

#sidebar.close .sidebar-header .logo_name,
#sidebar.close ul li a span,
#sidebar.close ul li .dropdown-menu-btn span,
#sidebar.close ul li .dropdown-menu-btn i:last-child {
    display: none !important;
}

#sidebar.close .sidebar-header .logo_square {
    display: block !important;
}

#sidebar.close .sub-menu {
    display: none !important;
}

#sidebar.close a, 
#sidebar.close .dropdown-menu-btn {
    width: 60px !important;
    justify-content: center !important;
    padding: 0 !important;
    text-align: center;
}

#sidebar.close a i,
#sidebar.close .dropdown-menu-btn i:first-child {
    margin: 0 !important;
    font-size: 1.25rem;
}

/* Nội dung thanh cuộn của Side Menu */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-content::-webkit-scrollbar {
    width: 5px;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background-color: rgba(128, 128, 128, 0.3);
    border-radius: 4px;
}

.sidebar-content:hover::-webkit-scrollbar-thumb {
    background-color: rgba(128, 128, 128, 0.6);
}

#sidebar ul {
    padding: 0;
    margin: 0;
    list-style: none;
}

#sidebar a, 
#sidebar .dropdown-menu-btn {
    text-decoration: none;
    color: var(--tef-sidebar-color);
    display: flex;
    align-items: center;
    gap: 0.85rem;
    height: 2.5rem;
    padding: 0 1rem;
    font-size: 0.875rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.dropdown-menu-btn {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
}

#sidebar a:hover, 
#sidebar .dropdown-menu-btn:hover {
    background-color: var(--tef-sidebar-hover);
    color: var(--tef-primary);
}

#sidebar li.active > a,
#sidebar .active {
    background-color: var(--tef-sidebar-hover);
    color: var(--tef-primary);
    font-weight: 600;
    border-left: 3px solid var(--tef-primary);
}

/* Accordion Sub-menu */
#sidebar .sub-menu {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease-in-out;
}

#sidebar .sub-menu > div {
    overflow: hidden;
}

#sidebar .sub-menu.show {
    grid-template-rows: 1fr;
}

#sidebar .dropdown-menu-btn i:last-child {
    margin-left: auto;
    transition: transform 0.2s ease;
}

#sidebar .dropdown-menu-btn.rotate i:last-child {
    transform: rotate(90deg);
}

#sidebar .sub-menu a {
    padding-left: 2.5rem;
    font-size: 0.825rem;
}

/* ==============================================================================
   2. MAIN CONTENT WRAPPER & HEADER CON CỦA MAIN CONTENT
   ============================================================================== */
#content-wrapper {
    width: calc(100% - 260px);
    position: relative;
    float: right;
    background-color: var(--bs-body-bg);
    height: 100vh;
    overflow: hidden;
    transition: width 0.3s ease;
}

#content-wrapper.active {
    width: calc(100% - 60px);
}

/* Header con của Main Content */
.main-topbar {
    height: 3rem;
    padding: 0 1rem;
    background-color: var(--tef-header-bg);
    border-bottom: 1px solid var(--bs-border-color);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1010;
}

.top_bar_button {
    background: none;
    border: none;
    color: var(--bs-body-color);
    width: 2.2rem;
    height: 2.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.top_bar_button:hover {
    background-color: var(--tef-sidebar-hover);
}

.main-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 3rem;
}

.top_bar_profile_picture {
    width: 32px;
    height: 32px;
    object-fit: cover;
}

.header_profile_picture_out {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto;
    cursor: pointer;
}

.header_profile_picture_out img {
    width: 80px;
    height: 80px;
    object-fit: cover;
}

/* User Profile & Notification Dropdown Menus */
.dropdown-menu.dropdown-menu-lg {
    min-width: 290px !important;
    width: 290px;
    padding: 0;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    overflow: hidden;
}

.dropdown-menu.dropdown-menu-lg .user-header {
    background-color: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color-translucent);
    text-align: center;
}

.dropdown-menu.dropdown-menu-lg .user-header p {
    color: var(--bs-body-color);
    line-height: 1.4;
    word-break: break-word;
}

.dropdown-menu.dropdown-menu-lg .user-footer {
    background-color: var(--bs-tertiary-bg);
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
}

.dropdown-menu.dropdown-menu-lg .user-footer .btn {
    flex: 1;
    white-space: nowrap;
    font-size: 0.8rem;
    padding: 0.35rem 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ==============================================================================
   3. MAIN CONTENT (TỰ CO GIÃN & SCROLL ĐỘC LẬP)
   ============================================================================== */
#main-content {
    position: absolute;
    top: 3rem;
    bottom: 3rem;
    left: 0;
    right: 0;
    height: calc(100vh - 6rem);
    overflow-y: auto;
    overflow-x: hidden;
    background-color: var(--bs-tertiary-bg);
    padding: 1rem;
}

#main-content::-webkit-scrollbar {
    width: 6px;
}

#main-content::-webkit-scrollbar-thumb {
    background-color: rgba(128, 128, 128, 0.3);
    border-radius: 4px;
}

#main-content:hover::-webkit-scrollbar-thumb {
    background-color: rgba(128, 128, 128, 0.6);
}

/* ==============================================================================
   4. FOOTER (CỐ ĐỊNH Ở ĐÁY MÀN HÌNH)
   ============================================================================== */
#main-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3rem;
    line-height: 3rem;
    background-color: var(--tef-header-bg);
    border-top: 1px solid var(--bs-border-color);
    padding: 0 1.5rem;
    z-index: 1010;
}

/* ==============================================================================
   5. BẢNG DỮ LIỆU, PHÂN TRANG & OVERLAY
   ============================================================================== */
.card-body.position-relative {
    position: relative;
    min-height: 240px;
}

/* Full-height Table Card Layout (Header trên cùng, Bảng full chiều cao còn lại, Phân trang dưới cùng) */
#main-content.storage-main-content {
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    padding: 0.75rem 1rem;
}

.storage-node-card {
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 0;
}

.storage-node-card-body {
    flex: 1 1 auto;
    min-height: 0 !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.storage-node-table-container {
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: auto;
}

#storageNodeTable thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--bs-tertiary-bg);
    box-shadow: inset 0 -1px 0 var(--bs-border-color);
    white-space: nowrap;
}

#storageNodeTable .dropdown-menu {
    position: fixed !important;
    z-index: 1060;
    margin: 0;
}

.overlay-wrapper,
.table-responsive {
    position: relative;
}

.modal-content {
    position: relative;
}

.modal-dialog-scrollable .modal-header,
.modal-dialog-scrollable .modal-footer {
    flex-shrink: 0 !important;
}

.modal-dialog-scrollable .modal-body {
    flex-grow: 1 !important;
    overflow-y: auto !important;
}

.overlay-wrapper .overlay,
.table-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background-color: var(--tef-overlay-bg);
    display: flex !important;
    flex-direction: column;
    justify-content: center !important;
    align-items: center !important;
    text-align: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex !important;
    flex-direction: column;
    justify-content: center !important;
    align-items: center !important;
    text-align: center;
    background-color: var(--tef-overlay-bg);
    z-index: 1055;
    border-radius: var(--bs-modal-border-radius, 0.375rem);
}

.overlay-wrapper .overlay.d-none,
.table-overlay.d-none,
.modal-overlay.d-none {
    display: none !important;
}

.btn-no-bg {
    background: none;
    border: none;
    box-shadow: none;
}

.form-control:focus,
.form-select:focus {
    box-shadow: none;
    border-color: var(--tef-primary);
}

/* ==============================================================================
   6. RESPONSIVE DESIGN (TABLET & MOBILE)
   ============================================================================== */
@media only screen and (max-width: 991px) {
    #sidebar {
        width: 60px;
    }
    #sidebar .sidebar-header .logo_name,
    #sidebar ul li a span,
    #sidebar ul li .dropdown-menu-btn span,
    #sidebar ul li .dropdown-menu-btn i:last-child {
        display: none;
    }
    #sidebar .sidebar-header .logo_square {
        display: block;
    }
    #content-wrapper {
        width: calc(100% - 60px);
    }
}

@media only screen and (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        width: 260px;
    }

    #sidebar.close {
        transform: translateX(0);
        box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.35);
        z-index: 1050;
        width: 260px !important;
    }

    #sidebar.close .sidebar-header {
        padding: 0 0.75rem;
        justify-content: flex-start;
    }

    #sidebar.close .sidebar-header .logo_square {
        display: none !important;
    }

    #sidebar.close .sidebar-header .logo_name {
        display: flex !important;
    }

    #sidebar.close ul li a span,
    #sidebar.close ul li .dropdown-menu-btn span,
    #sidebar.close ul li .dropdown-menu-btn i:last-child {
        display: inline-block !important;
    }

    #sidebar.close a,
    #sidebar.close .dropdown-menu-btn {
        width: 100% !important;
        justify-content: flex-start !important;
        padding: 0.6rem 1rem !important;
        text-align: left;
    }

    #sidebar.close a i,
    #sidebar.close .dropdown-menu-btn i:first-child {
        margin-right: 0.75rem !important;
        font-size: 1rem;
    }

    #content-wrapper,
    #content-wrapper.active {
        width: 100%;
        float: none;
    }

    .body-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        display: none;
        visibility: hidden;
        opacity: 0;
        z-index: 1040;
        background-color: rgba(0, 0, 0, 0.5);
        transition: opacity 0.3s ease;
    }

    .body-overlay.active {
        display: block;
        visibility: visible;
        opacity: 1;
    }
}

