main > .container, main > .container-fluid
{
    padding: 70px 15px 20px;
}

.footer {
    background-color: #f5f5f5;
    font-size: .9em;
    height: 60px;
}

.footer > .container, .footer > .container-fluid {
    padding-right: 15px;
    padding-left: 15px;
}

.not-set {
    color: #c55;
    font-style: italic;
}

/* add sorting icons to gridview sort links */
a.asc:after, a.desc:after {
    content: '';
    left: 3px;
    display: inline-block;
    width: 0;
    height: 0;
    border: solid 5px transparent;
    margin: 4px 4px 2px 4px;
    background: transparent;
}

a.asc:after {
    border-bottom: solid 7px #212529;
    border-top-width: 0;
}

a.desc:after {
    border-top: solid 7px #212529;
    border-bottom-width: 0;
}

.grid-view th,
.grid-view td:last-child {
    white-space: nowrap;
}

.grid-view .filters input,
.grid-view .filters select {
    min-width: 50px;
}

.hint-block {
    display: block;
    margin-top: 5px;
    color: #999;
}

.error-summary {
    color: #a94442;
    background: #fdf7f7;
    border-left: 3px solid #eed3d7;
    padding: 10px 20px;
    margin: 0 0 15px 0;
}

/* align the logout "link" (button in form) of the navbar */
.navbar form > button.logout {
    padding-top: 7px;
    color: rgba(255, 255, 255, 0.5);
}


/* 針對 AjaxCrudModal 的對話框按鈕進行反轉排列 */
#ajaxCrudModal .modal-footer {
    display: flex !important;
    flex-direction: row-reverse !important; /* 將按鈕順序反轉 */
    justify-content: flex-start !important;  /* 對齊右側 (或依需求改 center / space-between) */
    gap: 8px; /* 設定按鈕之間的間距 */
}

/* 確保取消按鈕在左側，確認按鈕在右側 */
#ajaxCrudModal .modal-footer .btn-default,
#ajaxCrudModal .modal-footer .btn-secondary {
    order: 2; /* 取消按鈕排在左側 */
}

#ajaxCrudModal .modal-footer .btn-primary,
#ajaxCrudModal .modal-footer .btn-success,
#ajaxCrudModal .modal-footer .btn-danger {
    order: 1; /* 確定按鈕排在右側 */
}


@media screen and (max-width: 767px) {
    .navbar form > button.logout {
        display: block;
        text-align: left;
        width: 100%;
        padding: 10px 0;
    }

    /* -------------------------------------------------- */
    /* Kartik GridView 手機版轉卡片 (完整修正版) */
    /* -------------------------------------------------- */

    /* 1. 隱藏表頭 */
    .kv-grid-table > thead {
        display: none !important;
    }

    /* 2. 所有 tr 轉為區塊卡片 */
    .kv-grid-table,
    .kv-grid-table tbody,
    .kv-grid-table tbody tr {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .kv-grid-table tbody tr {
        margin-bottom: 15px !important;
        border: 1px solid #dee2e6 !important;
        border-radius: 8px !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08) !important;
        background-color: #ffffff !important;
        padding: 6px 0 !important;
        overflow: hidden !important; /* 防止內部元素溢出卡片框 */
    }

    /* 3. 一般 td 轉為 Flex 靠左 */
    .kv-grid-table tbody td {
        display: flex !important;
        justify-content: flex-start !important;
        align-items: center !important;
        /* flex-wrap: wrap !important; /* <--- 加上這行，允許 td 內部的元素換行 */
        padding: 8px 15px !important;
        border: none !important;
        border-bottom: 1px solid #f1f3f5 !important;
        text-align: left !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .kv-grid-table tbody td:last-child {
        border-bottom: none !important;
    }

    /* 4. 有 data-label 的欄位加上 Badge 標籤 */
    .kv-grid-table tbody td[data-label]::before {
        content: attr(data-label);
        display: inline-block;
        font-size: 12px;
        font-weight: 600;
        color: #495057;
        background-color: #e9ecef;
        padding: 3px 8px;
        border-radius: 4px;
        margin-right: 10px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* 5. 無 data-label 的欄位 (如 #編號、操作按鈕) 置中 */
    .kv-grid-table tbody td[data-label=""]::before,
    .kv-grid-table tbody td:not([data-label])::before {
        display: none !important;
        content: "" !important;
    }

    .kv-grid-table tbody td[data-label=""],
    .kv-grid-table tbody td:not([data-label]) {
        justify-content: center !important;
        text-align: center !important;
        font-size: 1rem;
    }

    /* -------------------------------------------------- */
    /* 6. 展開明細欄位 (data-col-seq="1") 寬度與排版鎖定 */
    /* -------------------------------------------------- */

    /* 展開欄位：允許向下拉開，並嚴格限制 100% 寬度不溢出 */
    .kv-grid-table tbody td[data-col-seq="1"] {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 6px 10px !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important; /* 避免內頁把卡片撐爆 */
    }

    /* 鎖定點開後的明細容器：文字靠左、邊距修正 */
    .kv-expand-detail,
    .kv-expanded-row {
        text-align: left !important;
        justify-content: flex-start !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* 修正內頁 Bootstrap 的 row 負邊距 (margin-left/right: -15px)，防止向外推擠 */
    .kv-expand-detail .row,
    .kv-expanded-row .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    /* 確保 td 內部的 div 在換行時能自動佔滿整列 */
    .kv-grid-table tbody td > div {
        width: 100%;
    }
}

.navbar form > button.logout:focus,
.navbar form > button.logout:hover {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.75);
}

.navbar form > button.logout:focus {
    outline: none;
}

/* style breadcrumb widget as in previous bootstrap versions */
.breadcrumb {
    background-color: var(--bs-gray-200);
    border-radius: .25rem;
    padding: .75rem 1rem;
}

.breadcrumb-item > a
{
    text-decoration: none;
}

/*修正 Gridview 在 BootStrap 5 的顯示 */
.kv-panel-before, .kv-panel-after {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* 修正分頁元件在 BS5 預設可能過大的問題 */
.pagination {
    margin-bottom: 0;
}
.btn-toolbar {
    margin-left: auto !important; /* 強制把工具列推到最右邊 */
}

/* 教師調課預覽小視窗專用 CSS */
.ttip {
    position: relative;
    display: inline-block;
}
.ttip .tooltiptext {
    visibility: hidden;
    position: absolute;
    z-index: 1050;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.2s;
    background-color: #212529;
    padding: 3px;
    border-radius: 4px;
}
.ttip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}