/* =========================================
   TABLE OF CONTENTS
   1. VARIABLES & RESET
   2. LAYOUT STRUCTURE (Sidebar, Main Content)
   3. BASE COMPONENTS (Buttons, Links, Badges)
   4. FORM ELEMENTS (Inputs, Selects, Checkbox, Search)
   5. CONTAINERS (Cards, Stat Widgets)
   6. TABLE SYSTEM (Responsive Tables)
   7. NAVIGATION & PAGINATION
   8. SPECIFIC MODULES
      - Dashboard Home (Hero, Rank)
      - Course System (Cards, Swiper)
      - Modals
      - Department & Permissions
      - User Profile
   ========================================= */

/* =========================================
    1. VARIABLES & RESET
   ========================================= */
:root {
    /* Brand Colors */
    --BU-dashboard-main: #28ABC2;
    --BU-dashboard-main-lighter: #26C2DE;
    --BU-dashboard-main-darker: #1F8698;
    --BU-dashboard-secondary: #44ACE0;
    --BU-dashboard-secondary-darker: #2E97CC;
    /* Status Colors */
    --BU-dashboard-red: #F85E5E;
    --BU-dashboard-red-hover: #E43A3A;
    --BU-dashboard-orange: #FF9500;
    --BU-dashboard-green: #5ABC9D;
    /* Text & Background Colors */
    --BU-dashboard-text: #1D373B;
    --BU-dashboard-sub-text: #5C8188;
    --BU-dashboard-btn-text: #99B7BC;
    --BU-dashboard-bg: #EFF1F1;
    /* Dimensions */
    --sidebar-width: 240px;
}

body {
    font-family: 'Noto Sans TC', sans-serif;
    background-color: var(--BU-dashboard-bg);
    color: var(--BU-dashboard-text);
    -webkit-font-smoothing: antialiased;
}

/* =========================================
    2. LAYOUT STRUCTURE
   ========================================= */

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background-color: white;
    border-radius: 0 32px 32px 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: .3s ease;
    padding: 1.5rem;
}

.sidebar-logo {
    width: 100%;
}

.logo-img {
    width: auto;
    height: 48px;
    max-width: 136px;
}

/* Sidebar Navigation */
.nav-category {
    font-size: 0.8rem;
    color: var(--BU-dashboard-sub-text);
    padding: 1rem 0 0.5rem;
    letter-spacing: 0.5px;
    font-weight: 700;
}

.nav-link {
    color: var(--BU-dashboard-btn-text);
    padding: 0.25rem 0.5rem;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    border-radius: 50px;
    position: relative;
    overflow: hidden;
    z-index: 1;
    text-decoration: none;
    margin-top: 0.25rem;
}

    .nav-link:hover {
        color: var(--BU-dashboard-text);
        background-color: transparent;
    }

.sidebar .nav-link.active {
    background: linear-gradient(135deg, var(--BU-dashboard-main-lighter) 0%, var(--BU-dashboard-secondary) 100%);
    color: white !important;
    box-shadow: 0 4px 10px rgba(40, 171, 194, 0.3);
}

    .sidebar .nav-link.active i {
        color: white;
    }

/* User Profile (Sidebar Footer) */
.user-profile {
    margin-top: auto;
    padding: 1rem 0.5rem;
    border-top: 1px solid var(--BU-dashboard-bg);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.divide-line {
    width: 2px;
    height: 12px;
    background-color: var(--BU-dashboard-btn-text);
    border-radius: 50px;
}

/* --- Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 2rem;
    min-height: 100vh;
}

    .main-content h1 {
        font-size: 2rem;
        font-weight: 700;
        color: var(--BU-dashboard-main);
        line-height: 1.2;
        margin: 0 0 1.5rem 0;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

/* --- Layout RWD (< 992px) --- */
@media (max-width: 991.98px) {
    .sidebar {
        width: 100vw;
        height: auto;
        min-height: unset;
        max-width: 100vw;
        border-radius: 0 0 32px 32px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
        padding: 1rem 1.5rem 0.5rem 1.5rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .sidebar-logo {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    #sidebarNav, #sidebarProfile {
        display: none;
    }

    .sidebar.show-menu #sidebarNav,
    .sidebar.show-menu #sidebarProfile {
        display: flex;
    }

    #sidebarMenuBtn {
        font-size: 1.25rem;
        background: none;
        border: none;
        outline: none;
        color: var(--BU-dashboard-main);
    }

    .main-content {
        margin-left: 0;
        padding: 7rem 1rem 2rem 1rem;
    }
}

/* =========================================
    3. BASE COMPONENTS (Buttons, Links, Badges)
   ========================================= */

/* Buttons */
.btn-bu {
    border-radius: 50px;
    padding: 4px 24px;
    font-weight: 400;
    font-size: 1rem;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
}

.btn-bu-blue {
    background-color: var(--BU-dashboard-secondary);
    color: #fff;
}

    .btn-bu-blue:hover {
        background-color: var(--BU-dashboard-secondary-darker);
        color: #fff;
    }

.btn-bu-teal {
    background-color: var(--BU-dashboard-main);
    color: #fff;
}

    .btn-bu-teal:hover {
        background-color: var(--BU-dashboard-main-darker);
        color: #fff;
    }

.btn-bu-gray {
    background-color: var(--BU-dashboard-btn-text);
    color: #fff;
}

    .btn-bu-gray:hover {
        background-color: var(--BU-dashboard-sub-text);
        color: #fff;
    }

.btn-bu-outline {
    background-color: transparent;
    border-color: var(--BU-dashboard-main);
    color: var(--BU-dashboard-main);
}

    .btn-bu-outline:hover {
        border-color: var(--BU-dashboard-main-darker);
        color: var(--BU-dashboard-main-darker);
    }

/* Link Style Buttons */
a.btn-link {
    font-size: 0.9rem;
    color: var(--BU-dashboard-main);
    text-decoration: none;
    width: max-content;
    display: inline-block;
}

    a.btn-link.big {
        font-size: 1rem;
    }

    a.btn-link:hover {
        text-decoration: underline;
        color: var(--BU-dashboard-main-darker);
    }

    a.btn-link.dashboard-red-bg {
        color: var(--BU-dashboard-red);
    }

        a.btn-link.dashboard-red-bg:hover {
            color: var(--BU-dashboard-red-hover);
        }

/* Badges */
.badge-bu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 400;
    color: #fff;
    line-height: 1.2;
    min-width: 60px;
    white-space: nowrap;
}

.badge-bu-gray {
    background-color: var(--BU-dashboard-btn-text);
}

.badge-bu-orange {
    background-color: var(--BU-dashboard-orange);
}

.badge-bu-green {
    background-color: var(--BU-dashboard-green);
}

.badge-bu-red {
    background-color: var(--BU-dashboard-red);
}

.badge-bu-blue {
    background-color: var(--BU-dashboard-secondary-darker);
}

.identity.badge-bu {
    min-width: fit-content;
    padding: 2px;
}

.no-data-notification {
    color: var(--BU-dashboard-text);
    font-size: 1rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
}

    .no-data-notification a {
        color: var(--BU-dashboard-main);
        text-decoration: none;
        font-weight: 500;
    }

        .no-data-notification a:hover {
            text-decoration: underline;
            color: var(--BU-dashboard-main-darker);
        }

/* =========================================
    4. FORM ELEMENTS
   ========================================= */
.form-label {
    color: var(--BU-dashboard-text);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-control-bu, .form-select-bu {
    background-color: var(--BU-dashboard-bg);
    border: 1px solid transparent;
    border-radius: 50px;
    padding: 12px 24px;
    font-size: 1rem;
    color: var(--BU-dashboard-text);
    transition: .3s ease;
}

    .form-control-bu:focus, .form-select-bu:focus {
        background-color: #fff;
        border-color: var(--BU-dashboard-main);
        box-shadow: 0 0 0 4px rgba(40, 171, 194, 0.1);
        outline: none;
    }

.form-select-bu {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%231D373B' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1.5rem center;
    background-size: 16px 12px;
    cursor: pointer;
    min-width: 180px;
}

.form-select-bu-sm {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
    padding-left: 1rem;
    padding-right: 2rem !important;
    background-position: right 0.5rem center;
    font-size: 0.9rem;
    min-width: 140px;
}

.form-select-bu:disabled, .form-control-bu:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
    opacity: 0.7;
    border-color: transparent;
}

/* Search Wrapper */
.search-wrapper {
    position: relative;
    width: 100%;
}

    .search-wrapper .search-btn {
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        background: none;
        border: none;
        color: var(--BU-dashboard-main);
        font-size: 1rem;
        cursor: pointer;
        transition: .2s;
    }

        .search-wrapper .search-btn:hover {
            transform: translateY(-50%) scale(1.05);
        }

/* Custom Checkbox */
.custom-checkbox {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 24px;
    cursor: pointer;
    font-size: 1rem;
    color: var(--BU-dashboard-text);
    user-select: none;
    margin-top: 0;
    line-height: 1.5;
    width: fit-content;
    white-space: nowrap;
}

    .custom-checkbox.no-text {
        padding-bottom: 16px;
        padding-left: 0;
    }

    .custom-checkbox input {
        position: absolute;
        opacity: 0;
        cursor: pointer;
        height: 0;
        width: 0;
    }

.checkmark {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    height: 16px;
    width: 16px;
    background-color: transparent;
    border: 2px solid var(--BU-dashboard-btn-text);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.custom-checkbox:hover input ~ .checkmark {
    border-color: var(--BU-dashboard-main);
}

.custom-checkbox input:checked ~ .checkmark {
    background-color: var(--BU-dashboard-main);
    border-color: var(--BU-dashboard-main);
}

.checkmark:after {
    content: "\f00c";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    display: none;
    color: white;
    font-size: 12px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.custom-checkbox input:checked ~ .checkmark:after {
    display: block;
}

/* 增加一個錯誤狀態的樣式類別，讓 JS 切換更乾淨 */
.input-error-border {
    border: 1px solid var(--BU-dashboard-red) !important;
    border-radius: 8px;
    padding: 4px 8px; /* 增加一點內距讓紅框不要貼太近 */
}

/* =========================================
    5. CONTAINERS (Cards & Widgets)
   ========================================= */

/* Dashboard Card */
.dashboard-card {
    background: white;
    border-radius: 1rem;
    border: none;
    box-shadow: 2px 2px 10px rgba(40, 171, 194, 0.2);
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    height: 100%;
}

.card-header {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
    background: transparent;
    padding: 0;
    border: 0;
}

    .card-header .title-marker {
        width: 4px;
        height: 18px;
        background-color: var(--BU-dashboard-main-lighter);
        border-radius: 0 4px 4px 0;
        margin-right: 8px;
    }

    .card-header .title-text {
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--BU-dashboard-text);
        line-height: 1.2;
        margin: 0;
    }

/* Stat Widgets */
.stat-widget {
    background-color: #fff;
    border: 1px solid var(--BU-dashboard-main);
    border-radius: 8px;
    padding: 1rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: .2s ease;
}

    .stat-widget:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(38, 194, 222, 0.15);
    }

.widget-title {
    color: var(--BU-dashboard-sub-text);
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.widget-number {
    font-size: 2.75rem;
    font-weight: 700;
    color: var(--BU-dashboard-text);
    line-height: 1;
    white-space: nowrap;
}

.widget-unit {
    font-size: 1.75rem;
    font-weight: 400;
    color: var(--BU-dashboard-text);
    margin-left: 2px;
}


/* =========================================
    6. TABLE SYSTEM
   ========================================= */
.table-bu {
    width: 100%;
    margin-bottom: 0;
    vertical-align: middle;
    border-collapse: separate;
    border-spacing: 0;
}

    .table-bu thead th {
        font-size: 0.9rem;
        color: var(--BU-dashboard-sub-text);
        border-bottom: 1px solid var(--BU-dashboard-sub-text);
        padding: 0.75rem;
        background-color: #fff;
        white-space: nowrap;
        font-weight: 400;
    }

    .table-bu tbody td {
        padding: 0.75rem;
        color: var(--BU-dashboard-text);
        border-bottom: 1px solid var(--BU-dashboard-bg);
        background-color: #fff;
        font-size: 1rem;
    }

.table-responsive {
    border-radius: 12px;
    overflow: hidden;
}

/* Cell Profile Helper */
.cell-profile {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.4;
}

    .cell-profile .name {
        font-weight: 700;
        color: var(--BU-dashboard-text);
        font-size: 1rem;
    }

    .cell-profile .job-title {
        font-size: 0.9rem;
        color: var(--BU-dashboard-sub-text);
    }

/* --- Table Column Sizing --- */
/* Fit Content */
.t-col-fit, .t-col-sm, .t-col-md {
    width: 1%;
    white-space: nowrap;
}

.t-col-fit {
    min-width: 60px;
}

.t-col-sm {
    min-width: 90px;
}

.t-col-md {
    min-width: 160px;
}

/* Fluid Column */
.col-fluid {
    width: auto;
    white-space: normal;
    word-break: break-all;
    min-width: 120px;
}

/* --- 修課期間專用：控制斷行與手機版對齊 --- */
.period-col {
    white-space: nowrap; /* 大螢幕：強制單行不換行 */
}

/* 平板與較小螢幕：允許文字斷行變兩行 */
@media (max-width: 1199.98px) {
    .period-col {
        white-space: normal;
    }
}

/* 手機版卡片排版：確保靠左且標籤自動換行 */
@media (max-width: 991.98px) {
    .table-bu tbody td.period-col {
        flex-wrap: wrap; /* 允許內容與「已延後」標籤往下折行 */
        gap: 4px 8px; /* 設定文字與標籤之間的上下左右間距 */
        justify-content: flex-start; /* 確保內容緊密靠左對齊 */
    }
}

/* RWD: Hide specific columns */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .col-hide-laptop {
        display: none !important;
    }
}

/* --- Table Mobile Stack View (< 992px) --- */
@media (max-width: 991.98px) {
    .table-bu thead {
        display: none;
    }

    .table-bu, .table-bu tbody {
        display: block;
        width: 100%;
    }

        /* Default Card Style (Checkbox layout) */
        .table-bu tbody tr {
            display: grid;
            grid-template-columns: min-content 1fr 1fr;
            position: relative;
            background-color: #fff;
            margin-bottom: 1rem;
            border: 1px solid var(--BU-dashboard-bg);
            border-radius: 1rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
            padding: 0;
            overflow: hidden;
        }

        .table-bu tbody td {
            display: flex;
            align-items: center;
            padding: 0.5rem 1rem;
            border-bottom: none;
            min-height: 40px;
            font-size: 0.9rem;
            text-align: right;
        }

            .table-bu tbody td:first-child {
                grid-column: 1;
                grid-row: 1 / 100;
                justify-content: center;
                align-items: center;
                background-color: rgba(0, 0, 0, 0.02);
                border-right: 1px solid #EFF1F1;
                padding: 0 1rem;
                width: auto;
            }

                .table-bu tbody td:first-child .custom-checkbox {
                    margin-bottom: 0;
                }

        .table-bu .mobile-full {
            grid-column: 2 / -1 !important;
            justify-content: flex-start;
            text-align: left;
        }

        .table-bu tbody td::before {
            content: attr(data-label);
            color: var(--BU-dashboard-sub-text);
            font-size: 0.8rem;
            margin-right: 0.5rem;
            white-space: nowrap;
        }

        .table-bu .mobile-hide-label::before {
            display: none;
        }

        .table-bu .mobile-flex-row .cell-profile {
            flex-direction: row;
            align-items: center;
            gap: 8px;
        }

        /* No Checkbox Table */
        .table-bu.no-checkbox tbody tr {
            grid-template-columns: 1fr 1fr;
        }

        .table-bu.no-checkbox tbody td:first-child {
            grid-column: auto;
            grid-row: auto;
            justify-content: space-between;
            background-color: transparent;
            border-right: none;
            width: 100%;
            padding: 0.5rem 1rem;
        }

        .table-bu.no-checkbox .mobile-full {
            grid-column: 1 / -1 !important;
        }
}


/* =========================================
    7. NAVIGATION & PAGINATION
   ========================================= */

/* Pagination */
.pagination-bu {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 8px;
    align-items: center;
}

    .pagination-bu .page-link {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 32px;
        height: 32px;
        border-radius: 6px;
        color: var(--BU-dashboard-sub-text);
        text-decoration: none;
        font-size: 0.9rem;
        transition: all 0.2s;
        background-color: transparent;
        border: none;
    }

        .pagination-bu .page-link:hover {
            color: var(--BU-dashboard-text);
        }

        .pagination-bu .page-link.active {
            background: linear-gradient(135deg, var(--BU-dashboard-main-lighter) 0%, var(--BU-dashboard-secondary) 100%);
            color: white;
            font-weight: bold;
            box-shadow: 0 2px 4px rgba(40, 171, 194, 0.3);
        }

/* Nav Pills */
.nav-pills-bu {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding-left: 0;
    list-style: none;
}

    .nav-pills-bu .nav-item {
        display: flex;
        align-items: center;
    }

    .nav-pills-bu .nav-link {
        margin-top: 0;
        color: var(--BU-dashboard-btn-text);
        background-color: transparent;
        padding: 6px 16px;
        border-radius: 8px;
        font-size: 1rem;
        font-weight: 400;
        transition: .2s ease;
    }

        .nav-pills-bu .nav-link:hover {
            color: var(--BU-dashboard-text);
        }

        .nav-pills-bu .nav-link.active {
            background-color: var(--BU-dashboard-bg);
            color: var(--BU-dashboard-main);
            font-weight: 500;
        }

    .nav-pills-bu .nav-item:not(:last-child)::after {
        content: "|";
        color: var(--BU-dashboard-btn-text);
        font-weight: 300;
        margin-left: 8px;
        margin-right: 4px;
        opacity: 0.6;
    }


/* =========================================
    8. SPECIFIC MODULES
   ========================================= */

/* --- Module: Dashboard Home (Hero & Rank) --- */
.dashboard-hero {
    background: linear-gradient(100deg, var(--BU-dashboard-main) 0%, var(--BU-dashboard-secondary) 100%);
    border-radius: 1rem;
    color: white;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(40, 171, 194, 0.2);
}

.hero-stat-box {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    padding: 1.5rem;
    height: 100%;
    transition: transform 0.2s;
}

    .hero-stat-box:hover {
        background: rgba(255, 255, 255, 0.25);
        transform: translateY(-2px);
    }

/* Rank List */
.rank-list-item {
    display: flex;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--BU-dashboard-bg);
}

    .rank-list-item:last-child {
        border-bottom: none;
    }

.rank-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
    margin-right: 1rem;
    flex-shrink: 0;
    background-color: var(--BU-dashboard-main);
}

.rank-badge {
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

.badge-gold {
    color: #FFC107;
}

.badge-silver {
    color: #A0A0A0;
}

.badge-bronze {
    color: #CD7F32;
}

/* Slim Progress */
.progress-slim {
    height: 8px;
    border-radius: 10px;
    background-color: #E9ECEF;
}

    .progress-slim .progress-bar {
        background-color: var(--BU-dashboard-secondary);
    }


/* --- Module: Course System --- */
.course-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--BU-dashboard-btn-text);
    transition: .2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

    .course-card:hover {
        border: 1px solid var(--BU-dashboard-main);
        cursor: pointer;
    }

.course-img-box {
    height: 120px;
    position: relative;
    background-color: #f0f0f0;
    overflow: hidden;
    flex-shrink: 0;
}

    .course-img-box img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.3s ease;
    }

.course-body {
    padding: 0.8rem;
    position: relative;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.course-title {
    color: var(--BU-dashboard-text);
    font-weight: 700;
    font-size: 1rem;
}

.table-course-thumb {
    width: 100px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    margin-right: 12px;
    border: 1px solid #eee;
}

/* Swiper Overrides */
.btn-circle-arrow {
    width: 40px;
    height: 40px;
    color: var(--BU-dashboard-btn-text);
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    transition: all 0.2s;
}

    .btn-circle-arrow:hover {
        color: var(--BU-dashboard-text);
    }

.swiper-slide {
    height: auto;
}

.swiper-button-next, .swiper-button-prev {
    width: 40px !important;
    height: 40px !important;
    background-color: var(--BU-dashboard-bg);
    border-radius: 50%;
    color: var(--BU-dashboard-sub-text) !important;
    transition: all 0.2s;
}

    .swiper-button-next::after, .swiper-button-prev::after {
        font-size: 1rem !important;
        font-weight: bold;
    }

    .swiper-button-next:hover, .swiper-button-prev:hover {
        background-color: var(--BU-dashboard-main);
        color: white !important;
    }


/* --- Module: Modals --- */
.modal .table thead th {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

.modal-dialog-scrollable {
    height: calc(100% - 3.5rem);
}

    .modal-dialog-scrollable .modal-body .bu-popup-table,
    .modal-dialog-scrollable .modal-body .table-responsive {
        max-height: none !important;
        overflow: visible !important;
    }

.bu-popup-table {
    max-height: 400px;
    overflow-y: auto;
}

.selected-tag {
    color: var(--BU-dashboard-sub-text);
    font-size: 0.9rem;
    border-bottom: 1px solid var(--BU-dashboard-sub-text);
    padding-bottom: 0px;
    cursor: pointer;
    transition: color 0.2s;
}

    .selected-tag i:hover {
        color: var(--BU-dashboard-red);
        border-color: var(--BU-dashboard-red);
    }

    .selected-tag i {
        font-size: 0.8rem;
    }

/* Course Modal Specific */
.modal-tab-item {
    padding: 10px 4px;
    margin-right: 20px;
    font-size: 1.1rem;
    color: var(--BU-dashboard-btn-text);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

    .modal-tab-item:hover {
        color: var(--BU-dashboard-main);
    }

    .modal-tab-item.active {
        color: var(--BU-dashboard-main);
        font-weight: 700;
        border-bottom: 3px solid var(--BU-dashboard-main);
    }

.modal-course-img {
    width: 240px;
    height: 135px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #eee;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .modal-course-img {
        width: 100%;
        height: auto;
        aspect-ratio: 16/9;
    }
}

@media (max-height: 600px) {
    .modal-dialog-scrollable {
        height: 100%;
        margin: 0;
    }

    .modal-content {
        border-radius: 0 !important;
    }
}


/* --- Module: Department & Permissions --- */
.dept-list-container {
    background-color: var(--BU-dashboard-bg);
    border-radius: 12px;
    padding: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
}

.dept-link {
    display: block;
    padding: 8px 12px;
    color: var(--BU-dashboard-sub-text);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
    font-weight: 500;
}

    .dept-link:hover {
        color: var(--BU-dashboard-text);
        background-color: rgba(0, 0, 0, 0.05);
    }

    .dept-link.active {
        background-color: rgba(40, 171, 194, 0.1);
        color: var(--BU-dashboard-main);
        font-weight: 700;
    }

.dept-edit-item {
    padding: 0.5rem;
    border-bottom: 1px solid var(--BU-dashboard-bg);
    transition: background-color 0.2s;
}

    .dept-edit-item:last-child {
        border-bottom: 1px solid transparent;
    }

    .dept-edit-item:hover {
        background-color: var(--BU-dashboard-bg);
    }

    .dept-edit-item .custom-checkbox {
        margin-bottom: 0;
        width: 100%;
    }

/* Permission Grid */
.permission-list {
    display: grid;
    grid-template-columns: repeat(4, max-content);
    gap: 0.5rem 2rem;
    width: 100%;
}

.permission-item {
    display: inline-flex;
    align-items: center;
    color: var(--BU-dashboard-text);
    position: relative;
    padding-left: 14px;
    white-space: nowrap;
}

    .permission-item.unabled {
        color: var(--BU-dashboard-sub-text);
    }

    .permission-item::before {
        content: '';
        position: absolute;
        left: 0;
        width: 6px;
        height: 6px;
        background-color: var(--BU-dashboard-secondary);
        border-radius: 50%;
    }

    .permission-item.unabled::before {
        background-color: var(--BU-dashboard-btn-text);
    }

@media (max-width: 1400px) {
    .permission-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 991.98px) {
    .permission-list {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* --- Module: User Profile --- */
.avatar-upload-container {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    background-color: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-action-links {
    gap: 0.5rem;
    transition: gap 0.3s ease;
}

@media (max-width: 956px) {
    .user-action-links {
        gap: 1.5rem;
    }
}

/* 登入頁專屬樣式：覆寫 main-content 邊距並實現置中 */
body.login-page {
    background-color: var(--BU-dashboard-bg);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.login-page .main-content {
    margin-left: 0; /* 登入頁沒有 sidebar，移除左邊距 */
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.login-card {
    background: white;
    border-radius: 2rem;
    box-shadow: 0 10px 30px rgba(40, 171, 194, 0.1);
    width: 100%;
    max-width: 480px;
    padding: 3.5rem;
    text-align: left;
}

.login-logo {
    margin-bottom: 2.5rem;
}

    /* 設定 LOGO 圖片的高度，避免過大撐破版面 */
    .login-logo img {
        height: 48px;
        max-width: 100%;
        object-fit: contain;
    }

.login-card .form-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--BU-dashboard-text);
    margin-bottom: 0.75rem;
}

.login-card .form-control-bu {
    background-color: #F0F2F2; /* 依據截圖稍微深一點的灰色 */
    border: none;
    padding: 14px 24px;
    margin-bottom: 1.5rem;
}

.login-card .password-hint {
    font-size: 0.85rem;
    color: #99B7BC;
    margin-top: -1rem;
    margin-bottom: 2.5rem;
    display: block;
}

.login-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

    .login-actions .btn-bu {
        padding: 10px 30px;
        min-width: 120px;
    }

/* 響應式調整 */
@media (max-width: 576px) {
    .login-card {
        margin: 1.5rem;
        padding: 2.5rem 1.5rem;
    }
}
