/* ============================================================
   THREADS脆 爆紅文章 素材分析  —  Skin CSS
   /jpgtrend/skin/collect_materials.css
   ============================================================ */

/* ── 設計 Token ── */
body.page-jpgtrend-collect {
    --bg:          #07080b;
    --bg2:         #0d0f14;
    --panel:       #121520;
    --panel-2:     #181c27;
    --panel-3:     #1e2333;
    --text:        #e8edf5;
    --muted:       #7a8499;
    --line:        rgba(255,255,255,0.07);
    --line-2:      rgba(255,255,255,0.12);
    --orange:      #f59a23;
    --orange-glow: rgba(245,154,35,0.18);
    --orange-dim:  rgba(245,154,35,0.10);
    --blue:        #3fa9f5;
    --green:       #2ecc78;
    --red:         #f56565;
    --radius:      10px;
    --shadow:      0 8px 32px rgba(0,0,0,0.45);
}

body.page-jpgtrend-collect[data-theme="light"] {
    --bg:          #f4f7fb;
    --bg2:         #eef3f9;
    --panel:       #ffffff;
    --panel-2:     #f8fafc;
    --panel-3:     #e8eef6;
    --text:        #172033;
    --muted:       #667085;
    --line:        rgba(15,23,42,0.09);
    --line-2:      rgba(15,23,42,0.15);
    --orange:      #d97706;
    --orange-glow: rgba(217,119,6,0.16);
    --orange-dim:  rgba(217,119,6,0.10);
    --blue:        #0f72b8;
    --green:       #12805c;
    --red:         #dc2626;
    --shadow:      0 8px 28px rgba(15,23,42,0.08);
}

/* ── Reset ── */
.tm-shell *, .tm-shell *::before, .tm-shell *::after { box-sizing: border-box; margin: 0; padding: 0; }
.tm-shell a { color: inherit; }
.tm-shell img { display: block; }

/* ── Body ── */
body.page-jpgtrend-collect {
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 70% 40% at 50% -5%, rgba(245,154,35,0.06), transparent);
    color: var(--text);
    font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

body.page-jpgtrend-collect[data-theme="light"] {
    background-image:
        radial-gradient(ellipse 70% 40% at 50% -5%, rgba(56,189,248,0.16), transparent);
}

/* ── 頁面外殼 ── */
.tm-shell {
    width: min(1540px, calc(100% - 40px));
    margin: 0 auto;
    padding: 32px 0 64px;
}

/* ============================================================
   Header
   ============================================================ */
.tm-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--line);
}

.tm-header-left { flex: 1; min-width: 0; }

.tm-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--orange);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    margin-bottom: 8px;
    opacity: 0.9;
}
.tm-kicker::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    background: var(--orange);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--orange);
    animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.5; transform: scale(0.7); }
}

.tm-header h1 {
    font-size: 28px;
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 1.2;
    background: linear-gradient(90deg, #ffffff 0%, #c8d0e0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

body.page-jpgtrend-collect[data-theme="light"] .tm-header h1 {
    background: none;
    -webkit-text-fill-color: currentColor;
    color: var(--text);
}

.tm-header-desc {
    color: var(--muted);
    font-size: 13px;
}

.tm-period-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.tm-period-summary span,
.tm-period-stats span {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 6px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255,255,255,.025);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.tm-period-summary strong,
.tm-period-stats strong {
    color: var(--text);
    margin-left: 4px;
}

/* ── 右側表單 ── */
.tm-range-form {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    flex-shrink: 0;
    max-width: 620px;
}

.tm-range-form label {
    display: grid;
    gap: 5px;
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tm-range-shortcuts {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 1 1 100%;
    gap: 8px;
}

.tm-range-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid var(--line-2);
    border-radius: 999px;
    background: var(--panel);
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
    transition: border-color .15s, color .15s, background .15s, transform .15s;
}

.tm-range-pill:hover {
    border-color: rgba(245,154,35,0.45);
    color: var(--orange);
    background: var(--panel-2);
    transform: translateY(-1px);
}

.tm-range-pill.is-active {
    border-color: transparent;
    background: linear-gradient(135deg, #c97010 0%, #f59a23 100%);
    color: #1a0d00;
    box-shadow: 0 4px 12px rgba(245,154,35,0.28);
}

/* ============================================================
   Form Controls
   ============================================================ */
.tm-shell input, .tm-shell select, .tm-shell button {
    height: 38px;
    border-radius: 8px;
    border: 1px solid var(--line-2);
    background: var(--panel-2);
    color: var(--text);
    padding: 0 12px;
    font: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.tm-shell input:focus, .tm-shell select:focus {
    border-color: rgba(245,154,35,0.5);
    box-shadow: 0 0 0 3px rgba(245,154,35,0.08);
}
.tm-shell button {
    cursor: pointer;
    background: linear-gradient(135deg, #c97010 0%, #f59a23 50%, #ffcc6a 100%);
    border-color: transparent;
    color: #1a0d00;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 0.04em;
    padding: 0 18px;
    box-shadow: 0 2px 12px rgba(245,154,35,0.35);
    transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}
.tm-shell button:hover { transform: translateY(-1px); box-shadow: 0 4px 18px rgba(245,154,35,0.5); }
.tm-shell button:active { transform: translateY(0); }

/* ============================================================
   Stats Cards
   ============================================================ */
.tm-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.tm-period-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: -4px 0 18px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}

.tm-stat-card {
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.tm-stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--orange), transparent);
    opacity: 0;
    transition: opacity 0.2s;
}
.tm-stat-card:hover {
    border-color: var(--orange-dim);
    box-shadow: 0 4px 24px rgba(245,154,35,0.08);
}
.tm-stat-card:hover::before { opacity: 1; }

.tm-stat-card .stat-icon {
    font-size: 18px;
    margin-bottom: 10px;
    line-height: 1;
}
.tm-stat-card strong {
    display: block;
    font-size: 28px;
    font-weight: 900;
    color: var(--orange);
    letter-spacing: -0.02em;
    line-height: 1;
    margin-bottom: 4px;
}
.tm-stat-card span {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* ============================================================
   Toolbar
   ============================================================ */
.tm-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    margin-bottom: 16px;
}

.tm-toolbar input[type="search"] {
    min-width: 280px;
    flex: 1;
}

.tm-check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 38px;
    padding: 0 11px;
    border: 1px solid var(--line-2);
    border-radius: 8px;
    background: var(--panel-2);
    color: var(--text);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.tm-check input {
    width: 16px;
    height: 16px;
    padding: 0;
    accent-color: var(--orange);
}

.tm-shell .tm-button-muted {
    background: var(--panel-2);
    border-color: var(--line-2);
    color: var(--muted);
    box-shadow: none;
}

.tm-shell .tm-button-muted:hover {
    border-color: rgba(245,154,35,.45);
    color: var(--orange);
    background: var(--panel-3);
}

.tm-result-count {
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.tm-sort-hint {
    font-size: 11px;
    color: var(--muted);
    opacity: 0.7;
    white-space: nowrap;
    margin-left: 4px;
}

/* ============================================================
   Table
   ============================================================ */
.tm-table-wrap {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.tm-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 13px;
}

/* 表頭 */
.tm-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.tm-table th {
    padding: 12px 11px;
    background: var(--panel-2);
    border-bottom: 1px solid var(--line-2);
    color: var(--muted);
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* 可排序表頭 */
.tm-th-sort {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s, background 0.15s;
}
.tm-th-sort:hover {
    color: var(--orange);
    background: rgba(245,154,35,0.05);
}
.tm-sort-active {
    color: var(--orange) !important;
}
.sort-arrow {
    display: inline-block;
    width: 12px;
    font-size: 11px;
    opacity: 0.9;
    vertical-align: middle;
}

/* 欄寬 */
.tm-table th:nth-child(1)  { width: 118px; }  /* 時間 */
.tm-table th:nth-child(2)  { width: 130px; }  /* 作者 */
.tm-table th:nth-child(3)  { width: 105px; }  /* 主題 */
/* 第4欄：內容 (auto) */
.tm-table th:nth-child(5)  { width: 68px;  }  /* 預覽 */
.tm-table th:nth-child(6)  { width: 70px;  }  /* 媒體張數 */
.tm-table th:nth-child(7)  { width: 62px;  }  /* 讚 */
.tm-table th:nth-child(8)  { width: 62px;  }  /* 回覆 */
.tm-table th:nth-child(9)  { width: 62px;  }  /* 轉發 */
.tm-table th:nth-child(10) { width: 62px;  }  /* 分享 */
.tm-table th:nth-child(11) { width: 76px;  }  /* 分數 */
.tm-table th:nth-child(12) { width: 124px; }  /* 操作 */

/* 資料列 */
.tm-table td {
    padding: 11px 11px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.tm-table tbody tr {
    transition: background 0.12s;
}
.tm-table tbody tr:hover {
    background: rgba(255,255,255,0.025);
}
.tm-table tbody tr:last-child td {
    border-bottom: none;
}

/* 時間欄 */
.tm-time {
    color: var(--muted);
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* 作者 */
.tm-author {
    min-width: 0;
}
.tm-author img {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--panel-3);
    border: 1px solid var(--line-2);
    flex-shrink: 0;
}
.tm-author-name {
    font-size: 13px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 作者連結 */
.tm-author-link,
.tm-author-no-link {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--orange);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.15s;
    max-width: 100%;
}
.tm-author-link:hover {
    color: #ffd080;
    text-decoration: underline;
}
.tm-author-no-link {
    color: var(--text); /* 非連結狀態使用一般文字顏色 */
}

/* 主題標籤 */
.tm-topic {
    display: inline-block;
    background: var(--orange-dim);
    color: var(--orange);
    font-weight: 800;
    font-size: 12px;
    border-radius: 6px;
    padding: 3px 8px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 內容 */
.tm-content {
    display: -webkit-box;
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    text-align: left;
    cursor: pointer;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.6;
    color: #c5cbd8;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0;
}

.tm-shell .tm-content:hover,
.tm-shell .tm-content:focus {
    transform: none;
    box-shadow: none;
    color: var(--text);
}

.tm-content.is-expanded {
    display: block;
    overflow: visible;
    -webkit-line-clamp: unset;
}

/* 媒體張數為零 */
.tm-media-zero {
    color: var(--muted);
    opacity: 0.35;
    font-size: 13px;
}

/* 預覽縮圖 */
.tm-preview-wrap {
    display: inline-block;
    position: relative;
    cursor: zoom-in;
}

.tm-thumb {
    width: 54px;
    height: 54px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--panel-3);
    border: 1px solid var(--line-2);
    display: block;
}

.tm-media-badge {
    position: absolute;
    right: -6px;
    bottom: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--orange);
    color: #1a0d00;
    border: 2px solid var(--panel);
    font-size: 11px;
    font-weight: 900;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(245,154,35,0.35);
}

.tm-preview-popover {
    position: fixed;
    z-index: 99999;
    display: none;
    gap: 8px;
    max-width: min(520px, calc(100vw - 24px));
    padding: 10px;
    background: rgba(10, 12, 17, 0.96);
    border: 1px solid rgba(245,154,35,0.35);
    border-radius: 12px;
    box-shadow: 0 18px 48px rgba(0,0,0,0.65);
    pointer-events: none;
    overflow-x: auto;
}

.tm-preview-popover.active {
    display: flex;
}

.tm-preview-popover-img {
    width: 112px;
    height: 112px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--panel-3);
    border: 1px solid var(--line-2);
    flex: 0 0 auto;
}

.tm-media-count {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

/* 數字欄 */
.tm-metric {
    color: var(--green);
    font-family: Consolas, "Courier New", monospace;
    font-weight: 800;
    font-size: 13px;
    text-align: right;
    vertical-align: middle;
}

/* 互動分數欄 */
.tm-score {
    color: var(--orange);
    font-size: 14px;
    font-family: Consolas, "Courier New", monospace;
    font-weight: 900;
    text-align: right;
    vertical-align: middle;
}

/* 操作連結 */
.tm-link {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(63,169,245,0.12);
    color: var(--blue);
    border: 1px solid rgba(63,169,245,0.25);
    border-radius: 6px;
    text-decoration: none;
    font-weight: 800;
    font-size: 12px;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.tm-link:hover {
    background: rgba(63,169,245,0.22);
    border-color: rgba(63,169,245,0.5);
}

.tm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tm-shell .tm-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    min-width: 48px;
    padding: 4px 9px;
    border: 1px solid rgba(46,204,120,.25);
    border-radius: 6px;
    background: rgba(46,204,120,.1);
    color: var(--green);
    box-shadow: none;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
}

.tm-shell .tm-copy-btn:hover {
    border-color: rgba(46,204,120,.48);
    background: rgba(46,204,120,.18);
    box-shadow: none;
}

/* ============================================================
   狀態訊息
   ============================================================ */
.tm-error {
    padding: 18px 20px;
    border: 1px solid rgba(245,101,101,0.35);
    border-radius: var(--radius);
    background: rgba(245,101,101,0.07);
    color: #fca5a5;
    margin-bottom: 16px;
}

.tm-empty {
    display: none;
    padding: 40px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

body.page-jpgtrend-collect[data-theme="light"] .tm-period-summary span,
body.page-jpgtrend-collect[data-theme="light"] .tm-period-stats span {
    background: #f8fafc;
}

body.page-jpgtrend-collect[data-theme="light"] .tm-content {
    color: #344155;
}

body.page-jpgtrend-collect[data-theme="light"] .tm-content:hover,
body.page-jpgtrend-collect[data-theme="light"] .tm-content:focus {
    color: #111827;
}

body.page-jpgtrend-collect[data-theme="light"] .tm-preview-popover {
    background: rgba(255,255,255,.98);
    box-shadow: 0 18px 48px rgba(15,23,42,.18);
}

/* ============================================================
   分頁導覽
   ============================================================ */
.tm-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 32px;
    flex-wrap: wrap;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    transition: all 0.2s;
}

.page-link:hover {
    border-color: var(--orange-dim);
    color: var(--orange);
    background: var(--panel-2);
}

.page-link.active {
    background: linear-gradient(135deg, #c97010 0%, #f59a23 100%);
    color: #1a0d00;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(245,154,35,0.3);
}

.page-info {
    font-size: 13px;
    color: var(--muted);
    margin-left: 12px;
}

@media (max-width: 1024px) {
    .tm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
    .tm-shell { width: calc(100% - 24px); }
    .tm-header { flex-direction: column; align-items: stretch; }
    .tm-range-form { justify-content: flex-start; max-width: none; }
    .tm-range-shortcuts { justify-content: flex-start; overflow-x: auto; padding-bottom: 2px; }
    h1 { font-size: 22px; }
    .tm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .tm-table-wrap { overflow-x: auto; }
    .tm-table { min-width: 1120px; }
    .tm-pagination { gap: 5px; }
    .page-link { min-width: 34px; height: 34px; padding: 0 8px; font-size: 12px; }
}
