/* PsyTrack 前台樣式 */
:root {
    --psy-primary: #6366f1;
    --psy-radius: 8px;
    --psy-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --psy-fs: 15px;
}

.psy-track-year-list {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.psy-track-year-item {
    margin-bottom: 15px;
    border: 1px solid #e5e7eb;
    border-radius: var(--psy-radius);
    overflow: hidden;
    background: #fff;
    box-shadow: var(--psy-shadow);
}

.psy-track-year-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    transition: background 0.2s;
}

.psy-track-year-header:hover {
    background: #f3f4f6;
}

.psy-track-year-header h3 {
    margin: 0;
    font-size: var(--psy-fs);
    font-weight: 600;
    color: #374151;
}

.psy-track-toggle {
    font-size: 12px;
    color: #9ca3af;
    transition: transform 0.3s;
}

.psy-track-year-item.collapsed .psy-track-toggle {
    transform: rotate(-90deg);
}

.psy-track-year-content {
    max-height: 5000px;
    overflow: visible;
    transition: max-height 0.3s ease-out;
}

.psy-track-year-item.collapsed .psy-track-year-content {
    max-height: 0;
    overflow: hidden;
}

.psy-track-event-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.psy-track-event-item {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 16px;
    padding: 14px 18px;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.2s;
}

.psy-track-event-item:last-child {
    border-bottom: none;
}

.psy-track-event-item:hover {
    background: #fafbfc;
}

/* 日期欄位（包含日期和時間） */
.psy-track-event-date-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.psy-track-event-date {
    font-weight: 600;
    color: var(--psy-primary);
    font-size: calc(var(--psy-fs) - 1px);
    line-height: 1.5;
}

/* 連續型活動日期範圍 */
.psy-track-event-date-range {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.psy-track-event-date-divider {
    font-weight: 400;
    color: #9ca3af;
    font-size: calc(var(--psy-fs) - 3px);
    line-height: 1;
}

.psy-track-event-time {
    font-size: calc(var(--psy-fs) - 3px);
    color: #9ca3af;
    line-height: 1.4;
}

/* 活動資訊欄位（包含標題、地點、元數據） */
.psy-track-event-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* 活動標題行（包含標題和對象） */
.psy-track-event-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.psy-track-event-title {
    font-weight: 500;
    color: #1f2937;
    font-size: var(--psy-fs);
    line-height: 1.5;
}

/* 對象標籤 - 與地點、地區相同的低調樣式 */
.psy-track-event-target {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #9ca3af;
    font-size: calc(var(--psy-fs) - 3px);
    font-weight: 400;
}

.psy-track-event-location {
    font-size: calc(var(--psy-fs) - 1px);
    color: #6b7280;
    font-weight: 400;
    line-height: 1.4;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.psy-track-event-location::before {
    content: '🏠';
    font-size: 0.95em;
}

.psy-track-event-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: calc(var(--psy-fs) - 2px);
    margin-top: 2px;
}

.psy-track-event-meta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #6b7280;
    font-size: inherit;
}

/* 地區元數據特別樣式 - 更低調 */
.psy-track-event-meta:has(.psy-track-event-meta-icon:first-child) {
    color: #9ca3af;
    font-size: calc(var(--psy-fs) - 3px);
}

.psy-track-event-meta-icon {
    font-size: 0.9em;
    opacity: 0.7;
}

/* 分類篩選樣式 */
.psy-track-filter-container {
    display: flex;
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.psy-track-filter-sidebar {
    flex: 0 0 240px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: var(--psy-radius);
    padding: 18px;
    height: fit-content;
    position: sticky;
    top: 20px;
    box-shadow: var(--psy-shadow);
}

.psy-track-filter-sidebar h3 {
    margin: 0 0 14px 0;
    font-size: var(--psy-fs);
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid var(--psy-primary);
    padding-bottom: 8px;
}

.psy-track-category-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.psy-track-category-list li {
    margin-bottom: 6px;
}

.psy-track-category-btn {
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: calc(var(--psy-fs) - 2px);
    color: #374151;
}

.psy-track-category-btn:hover {
    background: #f9fafb;
    border-color: var(--psy-primary);
}

.psy-track-category-btn.active {
    background: var(--psy-primary);
    color: #fff;
    border-color: var(--psy-primary);
    font-weight: 500;
}

.psy-track-category-count {
    float: right;
    opacity: 0.7;
    font-size: 0.9em;
}

.psy-track-filter-content {
    flex: 1;
}

.psy-track-category-content {
    display: none;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: var(--psy-radius);
    padding: 18px;
    box-shadow: var(--psy-shadow);
}

.psy-track-category-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

.psy-track-category-content h3 {
    margin: 0 0 18px 0;
    font-size: calc(var(--psy-fs) + 1px);
    font-weight: 600;
    color: #1f2937;
    border-bottom: 2px solid var(--psy-primary);
    padding-bottom: 10px;
}

/* 簡單列表樣式 */
.psy-track-simple-list {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
    border-radius: var(--psy-radius);
    border: 1px solid #e5e7eb;
    box-shadow: var(--psy-shadow);
}

/* 資料夾式 (頁籤) 樣式 */
.psy-track-folder-container {
    max-width: 1000px;
    margin: 30px auto;
}

.psy-track-folder-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 10px 10px 0 10px;
    margin-bottom: -1px;
    position: relative;
    z-index: 2;
    mask-image: linear-gradient(to right, black 85%, transparent 100%);
}

.psy-track-folder-tabs::-webkit-scrollbar {
    display: none;
}

.psy-track-folder-tabs .psy-track-category-btn {
    flex: 0 0 auto;
    width: auto;
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    background: #f1f5f9;
    color: #64748b;
    padding: 12px 20px;
    font-weight: 500;
    border: 1px solid #e2e8f0;
    border-bottom-color: transparent;
    transition: all 0.2s ease;
    box-shadow: none;
    margin-right: -1px;
    font-size: calc(var(--psy-fs) - 1px);
}

.psy-track-folder-tabs .psy-track-category-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
    z-index: 3;
}

.psy-track-folder-tabs .psy-track-category-btn.active {
    background: #fff;
    color: var(--psy-primary);
    border-color: #e2e8f0;
    border-bottom-color: #fff;
    font-weight: 700;
    z-index: 4;
    position: relative;
}

/* 移除 active 狀態上方的藍色飾條，避免用戶誤解為多餘的線 */
.psy-track-folder-tabs .psy-track-category-btn.active::before {
    display: none;
}

.psy-track-folder-content {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0 var(--psy-radius) var(--psy-radius) var(--psy-radius);
    /* 左上角直角，配合頁籤 */
    padding: 30px;
    box-shadow: var(--psy-shadow);
    min-height: 400px;
    position: relative;
}

.psy-track-folder-container .psy-track-category-content {
    border: none;
    padding: 0;
    box-shadow: none;
}

/* 移除資料夾模式內標題的厚藍色底線 */
.psy-track-folder-container .psy-track-category-content h3 {
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 15px;
    color: #1e293b;
    font-size: calc(var(--psy-fs) + 3px);
}

.psy-track-simple-list h2 {
    margin: 0 0 18px 0;
    font-size: calc(var(--psy-fs) + 1px);
    font-weight: 600;
    color: #1f2937;
    border-bottom: 2px solid var(--psy-primary);
    padding-bottom: 10px;
}

/* 動畫 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 響應式設計 */
@media (max-width: 768px) {
    .psy-track-filter-container {
        flex-direction: column;
    }

    .psy-track-filter-sidebar {
        flex: 1;
        position: static;
    }

    .psy-track-event-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .psy-track-event-meta-row {
        gap: 8px;
    }
}

/* 前台分頁樣式 */
.psy-frontend-pagination {
    margin-top: 25px;
    margin-bottom: 25px;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.psy-frontend-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #374151;
    text-decoration: none;
    border-radius: 4px;
    font-size: calc(var(--psy-fs) - 2px);
    transition: all 0.2s;
}

.psy-frontend-pagination .page-numbers:hover {
    background: #f3f4f6;
    border-color: var(--psy-primary);
    color: var(--psy-primary);
}

.psy-frontend-pagination .page-numbers.current {
    background: var(--psy-primary);
    border-color: var(--psy-primary);
    color: #fff;
    cursor: default;
}

.psy-frontend-pagination .page-numbers.dots {
    border: none;
    background: transparent;
    cursor: default;
}



/* =========================================
   雙資料夾切換樣式 (極致層次版 - 消除死白區塊)
   ========================================= */

.psy-track-dual-folder-wrapper {
    display: flex;
    gap: 0;
    max-width: 1200px;
    margin: 0 auto;
    align-items: stretch;
}

/* --- 左側垂直分類 (懸浮書籤) --- */
.psy-track-taxonomy-selector {
    display: flex;
    flex-direction: column;
    padding-top: 65px;
    /* 對齊內容區頂部 */
    min-width: 60px;
    z-index: 3;
    /* 最高層級，確保壓在內容上 */
}

.psy-track-taxonomy-btn {
    writing-mode: vertical-rl;
    text-orientation: upright;
    padding: 24px 14px;

    background: #f3f4f6;
    /* 淺灰 */
    border: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;

    margin-right: -1px;
    /* 往右壓 */
    margin-bottom: -1px;
    /* 往下壓 */

    cursor: pointer;
    font-size: var(--psy-fs);
    font-weight: 500;
    color: #9ca3af;
    letter-spacing: 3px;

    border-radius: 8px 0 0 8px;
    transition: all 0.2s;
    position: relative;
}

.psy-track-taxonomy-btn:hover {
    background: #e5e7eb;
    color: #4b5563;
}

.psy-track-taxonomy-btn.active {
    background: #fff;
    /* 變白 */
    color: var(--psy-primary);
    font-weight: 700;

    /* 右邊框變成白色，與內容區打通 */
    border-right-color: #fff;
    border-color: #e5e7eb #fff #e5e7eb #e5e7eb;

    width: calc(100% + 1px);
    z-index: 10;
    box-shadow: -2px 2px 5px rgba(0, 0, 0, 0.02);
}

/* --- 右側主體 (關鍵修改：變透明！) --- */
.psy-track-dual-folder-main {
    flex: 1;
    background: transparent;
    /* [關鍵] 去除死白背景 */
    border: none;
    /* [關鍵] 去除大外框 */
    box-shadow: none;
    /* [關鍵] 去除大陰影 */
    display: flex;
    flex-direction: column;
    min-height: 500px;
    position: relative;
    z-index: 1;
}

/* --- 上方次分類 (懸浮頁籤) --- */
.psy-track-term-tabs-wrapper {
    background: transparent;
    /* 背景透明 */
    border-bottom: none;
    /* 下方邊線由內容區提供 */
    padding: 0 0 0 20px;
    /* 稍微往右縮一點 */
    margin-bottom: -1px;
    /* 往下壓，準備與內容區接合 */
    position: relative;
    z-index: 2;
}

.psy-track-term-tabs {
    display: none;
    flex-wrap: nowrap;
    gap: 0;
    margin-bottom: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-left: 1px;
    padding-top: 5px;
    /* 留一點空間給 hover浮動 */
}

.psy-track-term-tabs::-webkit-scrollbar {
    display: none;
}

.psy-track-term-tabs.active {
    display: flex;
}

/* 2. 頁籤按鈕 (一般狀態 - 縮在後面的索引標籤) */
.psy-track-term-btn {
    padding: 10px 24px;

    flex: 0 0 auto;
    width: auto;

    background: #f3f4f6;
    /* 淺灰，像沒抽出來的卡片 */
    color: #9ca3af;

    border: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    /* 未選中時底部要有線 */

    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: var(--psy-fs);
    font-weight: 500;
    position: relative;
    transition: all 0.2s;

    margin-right: -1px;
    transform: translateY(2px);
    /* 矮一點 */
}

.psy-track-term-btn:hover {
    background: #e5e7eb;
    color: #4b5563;
    z-index: 3;
}

.psy-track-term-btn.active {
    background: #fff;
    /* 變白 */
    color: var(--psy-primary);
    font-weight: 700;

    border: 1px solid #e5e7eb;
    border-bottom: 1px solid #fff;
    /* [關鍵] 下方變白，打通！ */
    border-top: 2px solid var(--psy-primary);
    /* 加強視覺焦點 */

    z-index: 5;
    transform: translateY(0);
    /* 彈出來 */
    padding-top: 9px;
    /* 微調高度 */
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.03);
}

/* 4. 計數器 */
.psy-track-term-count {
    font-size: 0.85em;
    opacity: 0.6;
    margin-left: 6px;
    background: rgba(0, 0, 0, 0.05);
    padding: 1px 6px;
    border-radius: 10px;
}

.psy-track-term-btn.active .psy-track-term-count {
    background: var(--psy-primary);
    color: #fff;
    opacity: 1;
}

/* --- 內容區域 (現在這裡才是真正的白色盒子) --- */
.psy-track-term-content-wrapper {
    background: #fff;
    /* 白色背景移到這裡 */
    border: 1px solid #e5e7eb;
    /* 邊框移到這裡 */
    border-radius: 0 8px 8px 8px;
    /* 左上角直角，配合左側標籤 */
    box-shadow: var(--psy-shadow);
    /* 陰影移到這裡 */
    padding: 30px;
    min-height: 400px;
    position: relative;
    z-index: 1;
}

.psy-track-term-content {
    display: none;
}

.psy-track-term-content.active {
    display: block;
    animation: psyFadeIn 0.3s ease;
}

/* --- 手機版響應式修正 --- */
@media (max-width: 768px) {
    .psy-track-dual-folder-wrapper {
        flex-direction: column;
    }

    .psy-track-taxonomy-selector {
        flex-direction: row;
        padding: 0 10px;
        margin-bottom: 0;
        background: #f8fafc;
        /* 背景稍暗一點，做出分層 */
        border-bottom: 1px solid #e5e7eb;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 5px;
        z-index: 10;
    }

    .psy-track-taxonomy-selector::-webkit-scrollbar {
        display: none;
        /* 隱藏捲軸但保持滾動 */
    }

    .psy-track-taxonomy-btn {
        writing-mode: horizontal-tb;
        text-orientation: mixed;
        padding: 14px 20px;
        border: none;
        border-radius: 0;
        margin: 0;
        white-space: nowrap;
        background: transparent;
        color: #64748b;
        position: relative;
        letter-spacing: 1px;
        font-size: var(--psy-fs);
    }

    .psy-track-taxonomy-btn::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 20%;
        right: 20%;
        height: 3px;
        background: var(--psy-primary);
        border-radius: 10px 10px 0 0;
        opacity: 0;
        transition: all 0.2s;
    }

    .psy-track-taxonomy-btn.active {
        color: var(--psy-primary);
        background: transparent;
        font-weight: 600;
        transform: none;
        box-shadow: none;
    }

    .psy-track-taxonomy-btn.active::after {
        opacity: 1;
        left: 10%;
        right: 10%;
    }

    .psy-track-dual-folder-main {
        padding-top: 0;
    }

    /* 第二層頁籤容器 */
    .psy-track-term-tabs-wrapper {
        background: #fff;
        padding: 12px 10px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
        z-index: 5;
    }

    .psy-track-term-btn {
        padding: 8px 15px;
        background: #f1f5f9;
        border: 1px solid transparent;
    }

    .psy-track-term-btn.active {
        background: #fff;
        border-color: #e5e7eb;
    }

    /* 內容區 */
    .psy-track-term-content-wrapper {
        border: none;
        border-top: 1px solid #f1f5f9;
        border-radius: 0;
        padding: 20px 15px;
        box-shadow: none;
    }

    .psy-folder-pane-title {
        font-size: 1.1em;
        margin-bottom: 20px;
    }
}

/* 瞬時分頁 - 頁面切換樣式 */
.psy-instant-page {
    display: none;
    list-style: none;
    padding: 0;
    margin: 0;
}

.psy-instant-page.active {
    display: block;
    animation: psyFadeIn 0.3s ease;
}

.psy-instant-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #f3f4f6;
}

.psy-instant-pagination a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 10px;
    border-radius: var(--psy-radius);
    background: #f3f4f6;
    color: #6b7280;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.25s ease;
}

.psy-instant-pagination a:hover {
    background: #e5e7eb;
    color: #1f2937;
}

.psy-instant-pagination a.current {
    background: var(--psy-primary);
    color: #fff;
    cursor: default;
}

.psy-instant-pagination a.disabled {
    opacity: 0.3;
    pointer-events: none;
    cursor: default;
}

.psy-pagination-dots {
    color: #9ca3af;
    padding: 0 4px;
    font-size: 14px;
    user-select: none;
}

@keyframes psyFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* AJAX Loading 狀態 */
.psy-ajax-list-container {
    transition: opacity 0.3s ease;
    min-height: 200px;
    /* 防止高度塌陷 */
    position: relative;
}

.psy-ajax-list-container.psy-loading {
    opacity: 0.5;
    pointer-events: none;
    /* 讀取時禁止再次點擊 */
}

/* 簡單的 Loading 轉圈圈 */
.psy-ajax-list-container.psy-loading::after {
    content: "";
    position: absolute;
    top: 100px;
    left: 50%;
    width: 30px;
    height: 30px;
    margin-left: -15px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--psy-primary);
    border-radius: 50%;
    animation: psySpin 0.8s linear infinite;
    z-index: 10;
}

@keyframes psySpin {
    to {
        transform: rotate(360deg);
    }
}

/* 查無紀錄提示 */
.psy-track-no-results {
    font-size: 13px !important;
    color: #94a3b8;
    padding: 30px 0;
    margin: 0;
    text-align: left;
    letter-spacing: 0.5px;
}