/* ============================================================
   主題變數:依院內衛教頁面的畫面估計的配色,可直接調整。
   主色(標題區塊、色條)、選單列、連結、卡片色調都在這裡。
   ============================================================ */
:root {
    --brand: #5a9faa;          /* 主色:標題區塊、色條、標籤文字 */
    --brand-deep: #3f7f8b;     /* 主色深一階:按鈕 hover */
    --brand-dark: #2c5f6b;     /* 段落大標題文字 */
    --brand-soft: #e8f3f3;     /* 提示框、淺底 */
    --nav-bg: #cfe3fb;         /* 選單列(淺藍) */
    --link: #2a69b8;           /* 連結色(院內網站 --template-link-color 實測值) */
    --text: #252525;           /* 內文顏色(院內網站 body 實測值) */
    --text-muted: #6b747c;
    /* 院內網站的其他範本色(實測值,尚未使用,需要時可套用):淺底 #f0f4fb、深灰文字 #495057、特殊深藍 #001b4c */
    --page-bg: #ffffff;
    --section-bg: #f4f8f9;
    --border: #dde5ea;
    --radius: 10px;
    --content-width: 1110px;   /* 內容區最大寬度(電腦版) */
    /* 院內網站 body 字型實測值(系統字型;中文由瀏覽器依 lang="zh-Hant" 選系統繁中字型,Windows 為微軟正黑體) */
    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";

    /* 彩色卡片色調:底色 / 左側色條 / 標題文字 */
    --tone-teal-bg: #e8f4f4;   --tone-teal: #5a9faa;   --tone-teal-text: #2c6b75;
    --tone-blue-bg: #edf3fa;   --tone-blue: #3f78a8;   --tone-blue-text: #2f5f8a;
    --tone-orange-bg: #fef5e6; --tone-orange: #d08a2b; --tone-orange-text: #8a5a12;
    --tone-green-bg: #eef3ee;  --tone-green: #6b8f6b;  --tone-green-text: #4a6a4a;
    --tone-red-bg: #fdeee8;    --tone-red: #c0705a;    --tone-red-text: #8a3f2e;
    --tone-gray-bg: #f1f3f5;   --tone-gray: #7a8a96;   --tone-gray-text: #4f5d68;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    background: var(--page-bg);
    color: var(--text);
    font-family: var(--font-body);
    /* 院內網站 body 實測值:行高 1.6(手機 1.35)、文字平滑 */
    line-height: 1.6;
    text-rendering: auto;
    -webkit-font-smoothing: antialiased;
    /* iPhone 瀏海 / 底部手勢區的安全邊界 */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
}

@media (max-width: 768px) {
    body {
        line-height: 1.35;
    }
}

a {
    color: var(--link);
}

.wrap {
    max-width: var(--content-width);
    margin: 0 auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Bootstrap 主要按鈕改用主題色 */
.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-deep);
    --bs-btn-hover-border-color: var(--brand-deep);
    --bs-btn-active-bg: var(--brand-deep);
    --bs-btn-active-border-color: var(--brand-deep);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
}

.btn-outline-primary {
    --bs-btn-color: var(--brand-deep);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand-deep);
    --bs-btn-active-border-color: var(--brand-deep);
}

/* 觸控目標至少 44px */
.btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ---------- 頁首(白底:機構名稱,可放 Logo)與選單列(淺藍) ---------- */
.site-header-top {
    background: #fff;
    padding-top: env(safe-area-inset-top);
}

.site-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    text-decoration: none;
    color: var(--text);
}

.site-logo {
    height: 52px;
    width: auto;
}

.site-brand-org {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.site-brand-app {
    display: block;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--brand-dark);
    line-height: 1.3;
}

.site-nav {
    background: var(--nav-bg);
    min-height: 48px;
}

.site-nav .wrap {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.nav-toggle {
    border: 0;
    background: none;
    font-size: 1.6rem;
    line-height: 1;
    padding: 0.4rem 0.25rem;
    min-width: 44px;
    min-height: 48px;
    color: var(--text);
}

.site-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: none;
    width: 100%;
    flex-direction: column;
}

.site-menu.open {
    display: flex;
}

.site-menu a,
.site-menu button {
    display: block;
    width: 100%;
    text-align: left;
    color: var(--text);
    text-decoration: none;
    background: none;
    border: 0;
    padding: 0.75rem 0.25rem;
    min-height: 44px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    font-size: 1rem;
}

@media (min-width: 768px) {
    .nav-toggle {
        display: none;
    }

    .site-menu {
        display: flex;
        flex-direction: row;
        width: auto;
        gap: 1.5rem;
    }

    .site-menu a,
    .site-menu button {
        border-top: 0;
        width: auto;
        padding: 0.75rem 0.25rem;
    }
}

/* ---------- 麵包屑 ---------- */
.breadcrumb-trail {
    font-size: 0.92rem;
    color: var(--text-muted);
    padding: 1rem 0 0.75rem;
    line-height: 1.7;
}

.breadcrumb-trail .sep {
    margin: 0 0.35rem;
}

.breadcrumb-trail .current {
    color: var(--text-muted);
}

.app-main {
    padding-bottom: 3rem;
}

/* ---------- 標題區塊(青藍底、圓角標籤、白色大標題) ---------- */
.hero {
    background: var(--brand);
    color: #fff;
    padding: 1.75rem 1.5rem 2rem;
}

.hero-pill {
    display: inline-block;
    background: rgba(0, 0, 0, 0.14);
    border-radius: 999px;
    padding: 0.55rem 1.2rem;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.1rem;
}

.hero-title {
    font-size: clamp(1.55rem, 5.2vw, 2.25rem);
    font-weight: 800;
    line-height: 1.5;
    margin: 0 0 1rem;
}

.hero-meta {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    line-height: 1.8;
    opacity: 0.95;
}

.hero-actions {
    margin-top: 1.1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.btn-hero {
    background: #fff;
    color: var(--brand-dark);
    border: 0;
    font-weight: 700;
    padding: 0.5rem 1.2rem;
    border-radius: 999px;
    text-decoration: none;
}

.btn-hero:hover {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

/* ---------- 內容段落(小標籤 + 大標題) ---------- */
.content-section {
    padding: 2rem 1.25rem 0.5rem;
}

.content-section.alt {
    background: var(--section-bg);
    padding-bottom: 2rem;
    margin-top: 1.5rem;
}

.eyebrow {
    color: var(--brand);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    margin: 0 0 0.35rem;
}

.section-title {
    color: var(--brand-dark);
    font-size: clamp(1.4rem, 4.5vw, 1.75rem);
    font-weight: 800;
    line-height: 1.5;
    margin: 0 0 1rem;
}

.sub-title {
    color: var(--brand-dark);
    font-size: 1.15rem;
    font-weight: 700;
    margin: 1.75rem 0 0.75rem;
}

.reading p,
.reading li {
    font-size: 1.08rem;
    line-height: 2;
    margin-bottom: 1rem;
}

.reading ul {
    padding-left: 1.4rem;
}

.reading .article-h2 {
    color: var(--brand-dark);
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1.5;
    margin: 2.25rem 0 0.9rem;
}

.reading .article-h3 {
    color: var(--brand-dark);
    font-size: 1.15rem;
    font-weight: 700;
    margin: 1.75rem 0 0.75rem;
}

/* 提示框:淺色底、左側粗色條 */
.callout {
    background: var(--brand-soft);
    border-left: 5px solid var(--brand);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
}

.callout p {
    margin: 0;
}

.abstract-label {
    color: var(--brand-dark);
}

/* ---------- 彩色卡片(左側色條) ---------- */
.tone-card {
    border-left: 5px solid var(--tone, var(--tone-teal));
    background: var(--tone-bg, var(--tone-teal-bg));
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 1rem 1.25rem;
}

.tone-teal { --tone: var(--tone-teal); --tone-bg: var(--tone-teal-bg); --tone-text: var(--tone-teal-text); }
.tone-blue { --tone: var(--tone-blue); --tone-bg: var(--tone-blue-bg); --tone-text: var(--tone-blue-text); }
.tone-orange { --tone: var(--tone-orange); --tone-bg: var(--tone-orange-bg); --tone-text: var(--tone-orange-text); }
.tone-green { --tone: var(--tone-green); --tone-bg: var(--tone-green-bg); --tone-text: var(--tone-green-text); }
.tone-red { --tone: var(--tone-red); --tone-bg: var(--tone-red-bg); --tone-text: var(--tone-red-text); }
.tone-gray { --tone: var(--tone-gray); --tone-bg: var(--tone-gray-bg); --tone-text: var(--tone-gray-text); }

/* ---------- 文章清單 ---------- */
.tab-bar {
    list-style: none;
    margin: 0 0 1.25rem;
    padding: 0;
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
}

.tab-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    min-height: 44px;
    border-radius: 999px;
    background: var(--section-bg);
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    font-size: 0.95rem;
}

.tab-link.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-weight: 700;
}

.tab-count {
    font-size: 0.8rem;
    opacity: 0.85;
}

.article-list {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .article-list {
        grid-template-columns: 1fr 1fr;
    }
}

.article-card {
    display: block;
    color: inherit;
    text-decoration: none;
}

.article-card:hover .article-card-title,
.article-card:active .article-card-title {
    text-decoration: underline;
}

.article-card-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
}

.article-card-site {
    color: var(--text-muted);
}

.article-card-title {
    color: var(--tone-text, var(--brand-dark));
    font-size: 1.08rem;
    font-weight: 700;
    line-height: 1.6;
    margin: 0.5rem 0 0.25rem;
}

.article-card-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 0 0.4rem;
}

.article-card-preview {
    font-size: 0.95rem;
    color: var(--text);
    line-height: 1.8;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.unread-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--tone-orange);
    display: inline-block;
}

.status-badge {
    display: inline-block;
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    background: #fff;
    color: var(--tone-text, var(--brand-dark));
    border: 1px solid var(--tone, var(--brand));
}

.pager {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.pager-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 1rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    text-decoration: none;
}

.pager-info {
    color: var(--text-muted);
}

.empty-state {
    background: var(--section-bg);
    border-radius: var(--radius);
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

/* ---------- 圖片 ---------- */
.article-figure {
    margin: 0 0 1.5rem;
}

.article-figure img {
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #fff;
}

.article-figure figcaption {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.8;
    margin-top: 0.5rem;
}

/* ---------- 回到頂端 ---------- */
.to-top {
    position: fixed;
    right: 1rem;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 6px;
    background: #2b2f33;
    color: #fff;
    font-size: 1.1rem;
    display: none;
    z-index: 20;
}

.to-top.show {
    display: block;
}

.back-link {
    display: inline-block;
    text-decoration: none;
    min-height: 44px;
    line-height: 44px;
}

/* ---------- 提示訊息 ---------- */
.flash {
    margin: 0.75rem 0 0;
    padding: 0.8rem 1rem;
    border-radius: 0 var(--radius) var(--radius) 0;
    border-left: 5px solid var(--tone-teal);
    background: var(--tone-teal-bg);
    line-height: 1.7;
}

.flash-warning {
    border-left-color: var(--tone-orange);
    background: var(--tone-orange-bg);
}

.flash-danger {
    border-left-color: var(--tone-red);
    background: var(--tone-red-bg);
}

/* ---------- 底部固定的審閱動作列(待處理的文章) ---------- */
.action-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    background: #fff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
    padding: 0.6rem 0 calc(0.6rem + env(safe-area-inset-bottom));
}

.action-bar-inner {
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
}

.action-bar-inner .btn {
    flex: 1 1 0;
    max-width: 280px;
}

body.has-action-bar .app-main {
    padding-bottom: 7rem;
}

body.has-action-bar .to-top {
    bottom: calc(5.5rem + env(safe-area-inset-bottom));
}

/* ---------- 衛教稿(閱讀與編輯) ---------- */
.edu-doc .edu-title {
    color: var(--brand-dark);
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1.6;
    margin: 0 0 1rem;
}

.edu-doc .edu-heading,
.edu-block .edu-heading {
    color: var(--brand-dark);
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.6;
    margin: 1.5rem 0 0.6rem;
}

.edu-paragraph {
    white-space: pre-line;   /* 段落內的換行照原樣顯示 */
}

.edu-doc .edu-list,
.edu-block .edu-list {
    padding-left: 1.4rem;
}

.edu-doc .edu-list li,
.edu-block .edu-list li {
    margin-bottom: 0.5rem;
}

/* 編輯器:每個區塊是一張可點的卡片 */
.edu-blocks {
    display: grid;
    gap: 0.75rem;
}

.edu-block {
    position: relative;
    border: 1px solid var(--border);
    border-left: 5px solid var(--brand);
    border-radius: 0 var(--radius) var(--radius) 0;
    background: #fff;
    padding: 1.9rem 1rem 0.5rem;
    cursor: pointer;
}

.edu-block:hover,
.edu-block:focus-visible {
    background: var(--section-bg);
    outline: none;
    border-color: var(--brand);
}

.edu-block-editing {
    cursor: default;
    background: var(--section-bg);
    padding-bottom: 1rem;
    box-shadow: 0 0 0 2px var(--brand-soft);
}

.edu-block-tag {
    position: absolute;
    top: 0.35rem;
    left: 1rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--brand);
}

.edu-block .edu-title {
    color: var(--brand-dark);
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1.6;
    margin: 0 0 0.5rem;
}

.edu-block .edu-heading {
    margin-top: 0;
}

.edu-block .edu-paragraph {
    margin: 0 0 0.5rem;
    line-height: 1.9;
}

.edu-block .callout {
    margin: 0 0 0.5rem;
}

.edu-input {
    line-height: 1.8;
    resize: vertical;
    min-height: 3.5rem;
}

.edu-input-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0.35rem 0 0;
}

.edu-block-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.edu-add {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.edu-add-label {
    font-weight: 700;
    color: var(--brand-dark);
}

.edu-bar {
    flex-wrap: wrap;
}

.edu-dirty {
    flex: 1 1 100%;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--tone-orange-text);
}

/* 版本紀錄 */
.edu-history {
    list-style: none;
    padding: 0;
    margin: 1.25rem 0;
    display: grid;
    gap: 0.75rem;
}

.edu-history-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.edu-history-link {
    font-weight: 700;
    font-size: 1.05rem;
}

.edu-history-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.edu-history-comment {
    margin-top: 0.25rem;
}

.article-card-edu {
    margin: 0.5rem 0 0;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--tone-text, var(--brand-dark));
}

/* ---------- 管理頁 ---------- */
.admin-grid {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .admin-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.admin-card-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--tone-text, var(--brand-dark));
    margin: 0 0 0.5rem;
}

.admin-stats {
    list-style: none;
    margin: 0;
    padding: 0;
}

.admin-stats li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.2rem 0;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.08);
}

.admin-table {
    font-size: 0.92rem;
}

.admin-table th {
    white-space: nowrap;
    background: var(--section-bg);
}

.admin-table td {
    vertical-align: middle;
}

.admin-title-cell {
    min-width: 16rem;
    max-width: 34rem;
}

.admin-muted {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.admin-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: end;
    margin-bottom: 1rem;
}

.admin-filter label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.admin-bulk {
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 0.75rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: end;
}

.admin-pre {
    background: var(--section-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.admin-detail dt {
    color: var(--text-muted);
    font-weight: 600;
}

.admin-detail dd {
    margin-bottom: 0.6rem;
}
