/* ==========================================================================
   PART A: Admin Styles (後台介面 - 現代化側邊欄佈局)
   ========================================================================== */

/* --- 佈局 (Layout) --- */
.ac-admin-wrapper {
    max-width: 1200px; /* 放寬寬度以容納側邊欄 */
    margin-top: 20px;
    box-sizing: border-box;
}

.ac-admin-wrapper * {
    box-sizing: border-box;
}

.ac-editor-header {
    margin-bottom: 20px;
}

.ac-layout-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.ac-main-column {
    flex: 3; /* 左側佔 75% */
    min-width: 0; /* 防止 flex item 溢出 */
}

.ac-sidebar-column {
    flex: 1; /* 右側佔 25% */
    min-width: 280px;
    position: sticky;
    top: 40px; /* 固定在頂部 */
}

/* --- 新增按鈕區塊 --- */
.ac-add-area {
    text-align: center;
    border: 2px dashed #ccc;
    padding: 30px;
    background: #f9f9f9;
    border-radius: 6px;
    margin-top: 20px;
    transition: background 0.2s;
}
.ac-add-area:hover {
    background: #f0f0f1;
    border-color: #bbb;
}
.button-hero {
    font-size: 16px !important;
    height: 46px !important;
    line-height: 44px !important;
    padding: 0 30px !important;
}

/* --- 側邊欄面板 (Panels) --- */
.ac-panel {
    background: #fff;
    border: 1px solid #dcdcde;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    margin-bottom: 20px;
    border-radius: 6px;
    overflow: hidden;
}

.ac-panel-header {
    padding: 12px 15px;
    border-bottom: 1px solid #eaecf0;
    font-weight: 600;
    font-size: 14px;
    background: #fcfcfc;
    color: #1d2327;
}

.ac-panel-body {
    padding: 15px;
}

.ac-field-group {
    margin-bottom: 15px;
}
.ac-field-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}
.ac-field-group input[type="text"] {
    width: 100%;
}

.w-100 { 
    width: 100%; 
    display: block; 
    text-align: center; 
    margin-bottom: 10px;
}

/* --- 群組卡片 (Group Card - Accordion) --- */
.ac-group-box {
    background: #fff;
    border: 1px solid #dcdcde;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
    margin-bottom: 15px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.ac-group-box:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    transform: translateY(-1px);
}

/* 收合狀態 */
.ac-group-box.closed .ac-group-body {
    display: none;
}
.ac-group-box.closed .ac-group-header {
    border-bottom: none;
}

/* 標頭美化 */
.ac-group-header {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #fff;
    border-bottom: 1px solid #eaecf0;
    padding: 15px 20px;
    cursor: pointer; /* 整條可點擊 */
    user-select: none;
}

.ac-group-header .handle {
    cursor: move;
    color: #a7aaad;
    font-size: 20px;
}
.ac-group-header .handle:hover {
    color: #2271b1;
}

/* 輸入框重置樣式 (融入背景) */
.group-title {
    border: 1px solid transparent !important;
    box-shadow: none !important;
    font-size: 15px !important;
    font-weight: 600;
    background: transparent !important;
    padding: 5px !important;
    transition: all 0.2s;
}
.group-title:focus, .group-title:hover {
    border-color: #2271b1 !important;
    background: #fff !important;
}

.group-taxonomy {
    border: 1px solid #dcdcde !important;
    background: #fff !important;
    color: #50575e;
    font-size: 13px;
    border-radius: 4px;
}

/* 收合箭頭 */
.toggle-indicator {
    margin-left: auto;
    color: #a7aaad;
    transition: transform 0.3s ease;
}
.ac-group-box.closed .toggle-indicator {
    transform: rotate(180deg);
}

/* --- 標籤搜尋區 (Body) --- */
.ac-group-body {
    padding: 20px;
    background: #fcfcfc;
    border-radius: 0 0 6px 6px;
}

.ac-search-area {
    position: relative;
    margin-bottom: 15px;
}

.ac-tag-search {
    width: 100%;
    padding: 10px 12px !important;
    border: 1px solid #dcdcde !important;
    border-radius: 4px;
    font-size: 14px;
}

/* 下拉建議選單 */
.ac-search-results {
    position: absolute;
    z-index: 999;
    background: #fff;
    border: 1px solid #ccd0d4;
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    margin: 5px 0 0;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-radius: 4px;
    list-style: none;
    padding: 0;
}

.ac-search-results li {
    padding: 10px 15px;
    margin: 0;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f1;
    font-size: 14px;
}
.ac-search-results li:hover {
    background: #f6f7f7;
    color: #2271b1;
}

/* --- 標籤樣式 (Chips/Badges) --- */
.ac-selected-tags {
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 10px;
}

.ac-tag-badge {
    background: #eef4f9; /* 淺藍色背景 */
    border: 1px solid #c5d9e8;
    color: #2c5979;
    padding: 6px 14px;
    border-radius: 100px; /* 膠囊形狀 */
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.ac-tag-badge:hover {
    background: #e0ecf5;
}

.ac-tag-badge .remove-tag {
    cursor: pointer;
    color: #8c99a6;
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
    display: flex;
    align-items: center;
}

.ac-tag-badge .remove-tag:hover {
    color: #d63638; /* 紅色 */
}

/* RWD */
@media(max-width: 960px) {
    .ac-layout-container { flex-direction: column; }
    .ac-sidebar-column { width: 100%; position: static; }
}


/* ==========================================================================
   PART B: Frontend Styles (前台介面)
   ========================================================================== */

.ac-filter-wrapper {
    margin-bottom: 40px;
    font-family: inherit;
    background: #fff;
    border: 1px solid #eee;
    padding: 25px;
    border-radius: 8px;
}

/* 篩選列 */
.ac-filter-row {
    display: flex;
    align-items: flex-start;
    margin-bottom: 20px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 20px;
}

.ac-filter-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.ac-label {
    width: 110px;
    font-weight: 700;
    font-size: 1.05em;
    padding-top: 7px;
    flex-shrink: 0;
    color: #333;
}

.ac-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    flex-grow: 1;
}

/* 選項按鈕 */
.ac-btn {
    background: #fff;
    border: 1px solid #e0e0e0;
    padding: 7px 18px;
    cursor: pointer;
    border-radius: 30px;
    transition: all 0.2s ease;
    font-size: 0.95em;
    color: #666;
    outline: none;
}

.ac-btn:hover {
    background: #f9f9f9;
    border-color: #bbb;
    color: #333;
}

.ac-btn.active {
    background: #f0c330; /* 激活色：黃色 */
    border-color: #f0c330;
    color: #fff;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(240, 195, 48, 0.3);
}

/* 搜尋動作區 */
.ac-action-area {
    text-align: center;
    margin: 30px 0;
}

.ac-search-btn {
    padding: 12px 50px;
    background: #333;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    border-radius: 4px;
    transition: background 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.ac-search-btn:hover {
    background: #000;
    transform: translateY(-1px);
}

.ac-search-btn:active {
    transform: translateY(1px);
}

.ac-search-btn:disabled {
    opacity: 0.7;
    cursor: wait;
    transform: none;
}

/* Grid 結果列表 */
.ac-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    transition: opacity 0.3s;
    min-height: 100px;
}

/* 文章卡片 */
.ac-card {
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.ac-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
}

.ac-card-image {
    position: relative;
    padding-top: 56.25%; /* 16:9 比例 */
    background: #f0f0f1;
    overflow: hidden;
}

.ac-card-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ac-card-image .no-thumb {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 0.9em;
}

.ac-card-content {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.ac-card-content h3 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
    line-height: 1.4;
    font-weight: 700;
}

.ac-card-content h3 a {
    text-decoration: none;
    color: #333;
    transition: color 0.2s;
}

.ac-card-content h3 a:hover {
    color: #f0c330;
}

.ac-card-meta {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 12px;
}

.ac-card-excerpt {
    font-size: 0.95rem;
    color: #666;
    line-height: 1.6;
    margin-bottom: 0;
}

.ac-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    background: #f9f9f9;
    color: #666;
    border-radius: 8px;
    font-size: 1.1em;
}

/* 手機版適應 */
@media(max-width: 768px) {
    .ac-filter-row {
        flex-direction: column;
    }
    .ac-label {
        margin-bottom: 10px;
    }
    .ac-btn {
        width: 100%; /* 手機版按鈕全寬更好按 */
        text-align: center;
    }
}