:root {
    --primary-color: #4a90e2;
    --card-bg: #ffffff;
    --text-main: #2c3e50;
    --text-sub: #7f8c8d;
}
/* 1. 調整外層容器，強制清除 Moodle 可能帶有的阻斷排版 */
.moodle-grid-container {
    display: block !important;
    width: 100%;
    clear: both;
}

/* 2. 讓卡片本身自帶橫向排列與間距屬性 */
.record-card {
    background: var(--card-bg);
    border-radius: 16px;
    
    /* 核心修改：利用 inline-block 讓卡片橫向並排 */
    display: inline-block !important;
    vertical-align: top;
    
    /* 控制單張卡片的寬度（可依畫面適度調整，例如 300px ~ 320px） */
    width: 310px; 
    
    /* 核心修改：為卡片四周加上間距（上下 15px，左右 15px） */
    margin: 15px 15px !important; 
    
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s ease;
    position: relative;
    border: 1px solid #edf2f7;
    text-align: left; /* 確保卡片內文字靠左 */
}

/* 滑鼠移上去時卡片浮起（保持不變） */
.record-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.12);
}

/* 封面圖片區塊 */
.card-cover {
    width: 100%;
    height: 180px;
    overflow: hidden;
    background-color: #f7fafc;
}

.card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 讓圖片自動填滿不變形 */
}

/* 內容區塊 */
.card-body {
    padding: 18px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* 標題樣式 */
.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 8px 0;
    line-height: 1.4;
width:100%;
   white-space: nowrap;   /* 必須：強制文字不換行 */
    overflow: hidden;      /* 必須：隱藏超出範圍的文字 */
    text-overflow: ellipsis; /* 必須：將超出部分顯示為 ... */
}

/* 說明文字樣式 */
.card-description {
    font-size: 0.9rem;
    color: var(--text-sub);
    line-height: 1.5;
    margin-bottom: 15px;
    flex-grow: 1; /* 讓說明區塊自動撐開 */
}

/* PDF 下載按鈕 */
.card-pdf-link img{ display:none}
.card-pdf-link a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 10px;
    background-color: #ff4757;
    color: #ffffff !important;
    text-decoration: none !important;
    border-radius: 10px;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.2s ease;
    box-shadow: 0 4px 6px rgba(255, 71, 87, 0.2);
   white-space: nowrap;   /* 必須：強制文字不換行 */
    overflow: hidden;      /* 必須：隱藏超出範圍的文字 */
    text-overflow: ellipsis; /* 必須：將超出部分顯示為 ... */
    
    vertical-align: middle;
}

.card-pdf-link a:hover {
    background-color: #ff6b81;
}

/* Moodle 右上角齒輪/管理選單工具列 */
.card-toolbar {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.85);
    padding: 4px 8px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    z-index: 5;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* 底部作者區塊 */
.card-footer {
    display: flex;
    align-items: center;
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #edf2f7;
    font-size: 13px;
}

.user-avatar img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-right: 10px;
}

.user-info a {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
}
/* --- 單筆檢視 (Single View) 專用樣式 --- */

.single-view-container {
    max-width: 900px; /* 限制寬度，讓閱讀更舒適 */
    margin: 20px auto;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    overflow: hidden;
    font-family: "Microsoft JhengHei", sans-serif;
    position: relative;
    border: 1px solid #eee;
}

/* 頂部大圖英雄區 */
.single-hero-image {
    width: 100%;
    height: 450px;
    overflow: hidden;
    background-color: #f0f2f5;
}

.single-hero-image img {
    width: 100%;
    height: 100%;
    max-width: 1024px;
    object-fit: cover; /* 確保圖片填滿且不變形 */
}

/* 內容主體區 */
.single-content {
    padding: 40px 50px;
}

/* 標題與管理選單 */
.single-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 25px;
}

.single-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: #1a202c;
    margin: 0;
    line-height: 1.2;
}

/* 作者與日期資訊 */
.single-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px dashed #e2e8f0;
}

.single-meta .user-avatar img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid #4a90e2;
}

.single-meta .meta-info {
    display: flex;
    flex-direction: column;
}

.single-meta .author-name {
    font-weight: bold;
    color: #4a90e2;
    font-size: 1.1rem;
}

.single-meta .post-date {
    font-size: 0.9rem;
    color: #a0aec0;
}

/* 說明文字區 */
.single-description {
    font-size: 1.15rem;
    line-height: 1.8;
    color: #4a5568;
    margin-bottom: 40px;
    white-space: pre-line; /* 保留換行 */
}

/* PDF 下載區域 (Call to Action) */
.single-action-box {
    background: #f8fafc;
    border-radius: 15px;
    padding: 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid #edf2f7;
}

.action-text h4 {
    margin: 0 0 5px 0;
    color: #2d3748;
}

.action-text p {
    margin: 0;
    font-size: 0.9rem;
    color: #718096;
}

/* 下載按鈕樣式 */
.single-pdf-btn a {
    background: linear-gradient(135deg, #ff4757, #ff6b81);
    color: white !important;
    padding: 12px 25px;
    border-radius: 12px;
    text-decoration: none !important;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 5px 15px rgba(255, 71, 87, 0.3);
    transition: transform 0.2s;
}

.single-pdf-btn a:hover {
    transform: scale(1.05);
}

.single-pdf-btn img{
    display:none;
}

/* Moodle 預設工具列定位 */
.single-toolbar {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
}
/* --- 進階搜尋區塊優化 --- */

/* 搜尋外殼 */
.moodle-search-container {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.04);
    border: 1px solid #edf2f7;
    max-width: 900px;
}

/* 標題 */
.search-box-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 表單橫向並排布局 */
.search-form-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

/* 單個輸入框群組 */
.search-group {
    flex: 1;
    min-width: 200px; /* 確保手機版會自動換行 */
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.search-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #4a5568;
}

/* 美化 Moodle 預設的文字輸入框 */
.search-group input[type="text"] {
    width: 100% !important;
    padding: 10px 14px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    font-size: 0.95rem !important;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: #f8fafc;
}

.search-group input[type="text"]:focus {
    border-color: #4a90e2 !important;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.15) !important;
    outline: none;
    background-color: #fff;
}

/* 按鈕區塊 */
.search-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    border-top: 1px solid #edf2f7;
    padding-top: 15px;
}

/* 美化儲存/重設按鈕 */
.search-buttons input[type="submit"], 
.search-buttons input[type="button"] {
    padding: 10px 20px !important;
    border-radius: 8px !important;
    font-weight: bold !important;
    font-size: 0.9rem !important;
    cursor: pointer;
    transition: all 0.2s;
    border: none !important;
}

/* 儲存設定按鈕 (深藍) */
.search-buttons input[name="save"] {
    background-color: #2d3748 !important;
    color: white !important;
}
.search-buttons input[name="save"]:hover {
    background-color: #1a202c !important;
}

/* 重設過濾器按鈕 (淺灰) */
.search-buttons input[name="reset"] {
    background-color: #e2e8f0 !important;
    color: #4a5568 !important;
}
.search-buttons input[name="reset"]:hover {
    background-color: #cbd5e1 !important;
}
/* 全域卡片容器 */
.video-pro-card {
    max-width: 680px;
    margin: 30px auto;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(149, 157, 165, 0.15);
    border: 1px solid #f0f2f5;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.video-pro-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(149, 157, 165, 0.22);
}

/* 頂部作者列 */
.v-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #fafbfc;
    border-bottom: 1px solid #f0f2f5;
}
.v-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.v-avatar img {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.v-meta {
    display: flex;
    flex-direction: column;
}
.v-author {
    font-size: 15px;
    font-weight: 600;
    color: #2c3e50;
}

.v-meta .post-date, .v-date  {
    font-size: 12px;
    color: #8a99a8;
    margin-top: 2px;
}
.v-actions .action-menu {
    display: inline-block;
}

/* 圖片與播放鈕區 */
.js-img-container {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    background: #000;
    aspect-ratio: 16 / 9; /* 強制保持標準影片比例 */
}
.js-img-container img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover; /* 確保各種尺寸圖片都不會變形 */
    display: block;
    transition: opacity 0.3s ease, transform 0.5s ease;
}
.js-img-container:hover img {
    opacity: 0.85;
    transform: scale(1.03);
}

/* 親和力播放按鈕（圓潤發光效果） */
.play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ffffff;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 2;
    pointer-events: none;
}
/* 讓播放圖示的小三角形微調居中 */
.play-btn i {
    font-size: 22px;
    color: #1e88e5; /* 採用充滿活力的陽光藍 */
    margin-left: 4px; 
}
.js-img-container:hover .play-btn {
    background: #1e88e5;
    transform: translate(-50%, -50%) scale(1.12);
    box-shadow: 0 8px 24px rgba(30, 136, 229, 0.4);
}
.js-img-container:hover .play-btn i {
    color: #ffffff;
}

/* 下方內文區 */
.v-card-body {
    padding: 24px 20px;
}
.v-title {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 12px 0;
    line-height: 1.4;
}
.v-desc {
    font-size: 15px;
    color: #5c6b73;
    line-height: 1.6;
}
/* 條列網格容器：調整卡片寬度為 320px */
/*
.v-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    padding: 15px 0;
}


.video-pro-card.list-mode {
    margin: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}
*/

/* 條列模式圖片高度固定 */
.video-pro-card.list-mode .js-img-container {
    aspect-ratio: 16 / 9;
}

/* 列表標題樣式 */
.video-pro-card.list-mode .v-title {
    font-size: 16px; /* 稍微縮小字體以符合小卡片 */
    margin-bottom: 6px;
    white-space: nowrap; /* 標題如果太長也強制一行 */
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 說明文字：嚴格限制只顯示「一行」，溢出顯示 ... */
.v-desc-short {
    font-size: 13px;
    color: #5c6b73;
    line-height: 1.4;
    
    /* 核心精要單行截斷技術 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; 
}

/* 列表底部功能列縮減 */
.v-card-footer {
    padding: 8px 15px;
    background: #fafbfc;
    border-top: 1px solid #f0f2f5;
    display: flex;
    justify-content: flex-end;
}
.v-more-link {
    font-size: 12px;
    color: #1e88e5;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}
/* 隱藏 Moodle 預設多餘的表格邊框 (若有) */
.v-grid-container table, .v-grid-container td {
    border: none !important;
}

/* 1. 強力修復 Moodle 內部表格結構，這能讓 Flex 網格生效 */
.v-grid-container table, 
.v-grid-container tr, 
.v-grid-container td { 
    display: contents !important; 
}

/* 2. 確保網格容器具備彈性 */
.v-grid-container {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 20px !important;
    justify-content: flex-start !important; /* 讓卡片從左往右排 */
    width: 100% !important;
}
/* ===================================================
   條列檢視：強力橫向網格並排修復（支援 RWD 自動換行）
   =================================================== */

/* 1. 捕捉 Moodle 資料庫可能產生的所有階層容器，通通強制轉為彈性並排 */
.mod-data-default-template,
.box.generalbox,
#region-main .box,
.defaulttemplate {
    display: flex !important;
    flex-direction: row !important; /* 強制橫向排列 */
    flex-wrap: wrap !important;     /* 寬度不夠時自動換行 */
    gap: 20px !important;           /* 卡片之間的精緻間距 */
    justify-content: flex-start !important; /* 從左邊開始排 */
    align-items: stretch !important;
    width: 100% !important;
}

/* 2. 徹底瓦解 Moodle 預設的 Table、表單等一筆一列的阻礙 */
.mod-data-default-template table,
.mod-data-default-template tr,
.mod-data-default-template td,
.mod-data-default-template tbody,
form[name="listform"],
div[id^="data-dir-"] {
    display: contents !important; /* 讓這些標籤失去包覆定位功能，使卡片直接面對最外層 Flex */
}

/* 3. 條列模式卡片核心：卡死 320px 寬度，並允許在彈性盒中並排 */
.video-pro-card.list-mode {
    width: 320px !important;
    max-width: 320px !important;
    min-width: 320px !important;
    flex: 0 1 320px !important; /* 縮寫形式：不放大、可縮小（若螢幕極窄）、基準 320px */
    margin: 0 !important;
    box-sizing: border-box !important;
    background: #ffffff;
    display: flex !important;
    flex-direction: column !important;
}

/* 4. 確保卡片內的圖片完美等比例 */
.video-pro-card.list-mode .js-img-container {
    width: 100% !important;
    aspect-ratio: 16 / 9 !important;
}

/* 5. 強制標題與說明文字嚴格單行截斷 (...) */
.video-pro-card.list-mode .v-title,
.video-pro-card.list-mode .v-desc-short {
    display: block !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    width: 100% !important;
}