: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;
}

/* 說明文字樣式 */
.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;
}