/* ============================================
   未來智慧所 — 白底藍色系主題
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700;900&display=swap');

:root {
  --bg: #f5f7fb;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #f1f5fb;
  --border: #dde5f0;
  --text: #1e293b;
  --text-dim: #64748b;
  --primary: #2563eb;
  --primary-dark: #1e3a8a;
  --grad: linear-gradient(120deg, #2563eb, #1d4ed8);
  --radius: 14px;
  --shadow: 0 6px 24px rgba(30, 58, 138, .10);
  --shadow-sm: 0 2px 10px rgba(30, 58, 138, .06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(37, 99, 235, .06), transparent),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(30, 58, 138, .05), transparent);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container { width: min(1140px, 92%); margin: 0 auto; }
main.container { flex: 1; padding: 28px 0 60px; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--text-dim); }
code { background: var(--panel-2); padding: 2px 7px; border-radius: 6px; font-size: .9em; color: var(--primary-dark); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.header-inner { display: flex; align-items: center; gap: 24px; padding: 14px 0; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none !important; }
.logo-mark { width: 36px; height: 36px; display: block; }
.logo-text {
  font-weight: 900; font-size: 1.25em; letter-spacing: .06em;
  color: #56698f; /* 品牌標準色 */
}
.logo:hover .logo-text { color: var(--primary); }
.main-nav { display: flex; gap: 18px; align-items: center; }
.main-nav > a, .dropdown > a { color: var(--text); font-weight: 500; text-decoration: none !important; padding: 6px 2px; }
.main-nav > a:hover, .dropdown > a:hover { color: var(--primary); }
.nav-admin { color: var(--primary-dark) !important; font-weight: 700 !important; }

.dropdown { position: relative; }
.dropdown-menu {
  display: none; position: absolute; top: 100%; left: -10px; min-width: 180px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 8px; z-index: 50;
}
.dropdown:hover .dropdown-menu { display: block; }
.dropdown-menu a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--text); text-decoration: none !important; }
.dropdown-menu a:hover { background: var(--panel-2); color: var(--primary); }

.header-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.search-form input {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 16px; color: var(--text); width: 180px; outline: none; transition: .2s;
}
.search-form input:focus { border-color: var(--primary); background: #fff; width: 230px; }
.user-chip { color: var(--text-dim); font-size: .9em; white-space: nowrap; text-decoration: none !important; }
.user-chip:hover { color: var(--primary); }
.role-form select { width: auto; padding: 6px 10px; font-size: .9em; }

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-block; border: 1px solid transparent; border-radius: 10px;
  padding: 10px 20px; font-size: .95em; font-weight: 500; cursor: pointer;
  font-family: inherit; text-decoration: none !important; transition: .18s; text-align: center;
}
.btn-primary {
  background: var(--grad); color: #fff; font-weight: 700; border: none;
  box-shadow: 0 3px 10px rgba(37, 99, 235, .3);
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 12px; font-size: .85em; border-radius: 8px; }
.btn-block { display: block; width: 100%; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 64px 0 40px; }
.hero h1 { font-size: clamp(1.8em, 4.5vw, 3em); font-weight: 900; letter-spacing: .02em; color: var(--primary-dark); }
.hero .grad {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.hero p { color: var(--text-dim); font-size: 1.1em; margin-top: 12px; }

/* ---------- 分類 pills ---------- */
.cat-pills { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0 28px; }
.pill {
  padding: 7px 18px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; color: var(--text-dim); text-decoration: none !important; font-size: .92em; transition: .18s;
}
.pill:hover { border-color: var(--primary); color: var(--primary); }
.pill.active { background: var(--grad); color: #fff; font-weight: 700; border-color: transparent; }

/* ---------- 文章卡片 ---------- */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 22px; }
.post-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden; transition: .2s;
  box-shadow: var(--shadow-sm);
}
.post-card:hover { transform: translateY(-4px); border-color: rgba(37, 99, 235, .45); box-shadow: var(--shadow); }

.post-thumb {
  display: block; aspect-ratio: 16 / 9; overflow: hidden;
  background: linear-gradient(135deg, #dbeafe, #e0e7ff 55%, #ede9fe);
  position: relative;
}
.post-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s;
}
.post-card:hover .post-thumb img { transform: scale(1.05); }
.thumb-fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 3em; opacity: .8;
}

.post-card-body { padding: 20px 22px 12px; flex: 1; }
.post-card h3 { margin: 10px 0 8px; font-size: 1.15em; line-height: 1.5; }
.post-card h3 a { color: var(--text); text-decoration: none !important; }
.post-card h3 a:hover { color: var(--primary); }
.excerpt { color: var(--text-dim); font-size: .92em; }
.post-card-meta {
  display: flex; gap: 14px; padding: 12px 22px; border-top: 1px solid var(--border);
  color: var(--text-dim); font-size: .82em;
}
.tag {
  display: inline-block; font-size: .78em; padding: 3px 10px; border-radius: 999px;
  background: rgba(37, 99, 235, .09); color: var(--primary); text-decoration: none !important; font-weight: 500;
}
.tag-draft { background: rgba(217, 119, 6, .1); color: #b45309; }
.tag-pub { background: rgba(22, 163, 74, .1); color: #15803d; }

.section-head { margin: 8px 0 22px; }
.section-head h2 { font-size: 1.5em; color: var(--primary-dark); }
.empty-state {
  text-align: center; color: var(--text-dim); padding: 70px 0;
  border: 1px dashed var(--border); border-radius: var(--radius); margin-top: 10px; background: #fff;
}

/* ---------- 分頁 ---------- */
.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 36px; }
.pagination a {
  min-width: 38px; text-align: center; padding: 7px 0; border-radius: 9px;
  border: 1px solid var(--border); background: #fff; color: var(--text-dim); text-decoration: none !important;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination a.active { background: var(--grad); color: #fff; font-weight: 700; border-color: transparent; }

/* ---------- 文章頁 ---------- */
.article-page { max-width: 800px; margin: 0 auto; }
.article-head h1 { font-size: clamp(1.5em, 3.5vw, 2.2em); margin: 14px 0 10px; line-height: 1.4; color: var(--primary-dark); }
.article-meta { display: flex; gap: 18px; align-items: center; color: var(--text-dim); font-size: .9em; flex-wrap: wrap; }
.article-actions { position: relative; margin: 22px 0; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.article-cover { width: 100%; border-radius: var(--radius); margin: 4px 0 18px; box-shadow: var(--shadow-sm); }

.save-panel {
  position: absolute; top: 110%; left: 0; z-index: 60; width: min(360px, 90vw);
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 18px;
}
.save-panel h4 { margin-bottom: 10px; }
.coll-row { display: flex; align-items: center; gap: 10px; padding: 7px 4px; cursor: pointer; border-radius: 8px; }
.coll-row:hover { background: var(--panel-2); }
.coll-row input { accent-color: var(--primary); width: 16px; height: 16px; }
.coll-new { display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.coll-new input { flex: 1; }

.article-content { font-size: 1.05em; }
.article-content h1, .article-content h2, .article-content h3 { margin: 1.4em 0 .5em; line-height: 1.45; color: var(--primary-dark); }
.article-content h2 { padding-left: 12px; border-left: 4px solid var(--primary); }
.article-content p { margin: .8em 0; }
.article-content ul, .article-content ol { margin: .8em 0 .8em 1.6em; }
.article-content li { margin: .3em 0; }
.article-content blockquote {
  margin: 1.2em 0; padding: 14px 20px; border-left: 4px solid var(--primary);
  background: var(--panel-2); border-radius: 0 10px 10px 0; color: var(--text-dim);
}
.article-content pre, .article-content .ql-code-block-container {
  background: #0f172a; color: #e2e8f0; border-radius: 10px;
  padding: 16px 18px; overflow-x: auto; margin: 1.2em 0;
  font-family: 'Cascadia Code', Consolas, monospace; font-size: .9em;
}
.article-content img { max-width: 100%; border-radius: 10px; margin: 1em 0; }
.article-content iframe, .article-content video { max-width: 100%; border-radius: 10px; margin: 1em 0; }
.article-content table { border-collapse: collapse; width: 100%; margin: 1.2em 0; }
.article-content th, .article-content td { border: 1px solid var(--border); padding: 9px 14px; }
.article-content th { background: var(--panel-2); }

/* ---------- 收藏頁 ---------- */
.coll-new-bar { display: flex; gap: 10px; margin-bottom: 26px; max-width: 480px; }
.coll-new-bar input { flex: 1; }
.coll-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.coll-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; transition: .2s; display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-sm);
}
.coll-card:hover { border-color: rgba(37, 99, 235, .5); transform: translateY(-3px); box-shadow: var(--shadow); }
.coll-card-link { text-decoration: none !important; color: var(--text); }
.coll-icon { font-size: 2em; }
.coll-name { margin: 6px 0 2px; }
.coll-card-actions { display: flex; gap: 8px; margin-top: auto; }

.coll-items { display: flex; flex-direction: column; gap: 16px; }
.coll-item {
  display: flex; gap: 18px; justify-content: space-between;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.coll-item-main { flex: 1; }
.coll-item-main h3 { margin: 8px 0 6px; }
.coll-item-main h3 a { color: var(--text); text-decoration: none !important; }
.coll-item-main h3 a:hover { color: var(--primary); }
.coll-item-side { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; font-size: .85em; white-space: nowrap; }
.note-box { margin-top: 12px; }
.note-box label { display: block; font-size: .82em; margin-bottom: 5px; }
.note-box textarea {
  width: 100%; min-height: 60px; resize: vertical;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px;
  color: var(--text); padding: 10px 12px; font-family: inherit; font-size: .92em; outline: none;
}
.note-box textarea:focus { border-color: var(--primary); background: #fff; }
.note-status { color: #15803d; font-size: .82em; margin-left: 6px; }

/* ---------- 表單 ---------- */
label { display: block; margin: 14px 0 6px; font-size: .92em; color: var(--text-dim); }
input[type=text], input[type=password], input[type=email], input[type=search],
input[type=number], select, textarea {
  width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); padding: 11px 14px; font-family: inherit; font-size: 1em; outline: none; transition: .18s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.search-form input { width: 180px; }
.coll-new-bar input, .coll-new input { width: auto; }
form button[type=submit] { margin-top: 20px; }

/* ---------- 登入 / 註冊 ---------- */
.auth-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 4%; min-height: 100vh; }
.auth-card {
  width: min(420px, 100%); background: var(--panel); border: 1px solid var(--border);
  border-radius: 18px; padding: 38px 34px; box-shadow: var(--shadow); text-align: center;
}
.auth-card h2 { margin: 14px 0 18px; color: var(--primary-dark); }
.auth-card form { text-align: left; }
.auth-brand {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-decoration: none !important; margin-bottom: 6px;
}
.auth-brand img { width: 64px; height: 64px; }
.auth-brand .logo-text { font-size: 1.4em; }

/* ---------- 提示 ---------- */
.alert { padding: 13px 18px; border-radius: 11px; margin: 14px 0; font-size: .95em; }
.alert-success { background: rgba(22, 163, 74, .08); border: 1px solid rgba(22, 163, 74, .35); color: #15803d; }
.alert-error { background: rgba(220, 38, 38, .07); border: 1px solid rgba(220, 38, 38, .35); color: #b91c1c; }

/* ---------- 後台 ---------- */
.admin-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-bottom: 24px; }
.admin-head h2 { color: var(--primary-dark); }
.admin-nav { display: flex; gap: 10px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 34px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center; box-shadow: var(--shadow-sm);
}
.stat-num {
  font-size: 1.9em; font-weight: 900;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.stat-label { color: var(--text-dim); font-size: .88em; }

.data-table {
  width: 100%; border-collapse: collapse; background: var(--panel);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.data-table th, .data-table td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { background: var(--panel-2); color: var(--text-dim); font-weight: 500; font-size: .88em; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(37, 99, 235, .03); }
.row-actions { white-space: nowrap; }
.row-actions form button { margin: 0; }

.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 26px; align-items: start; }
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow-sm);
}

/* ---------- 編輯器 ---------- */
.editor-layout { display: grid; grid-template-columns: 1fr 280px; gap: 26px; align-items: start; }
.title-input { font-size: 1.35em; font-weight: 700; margin-bottom: 14px; padding: 14px 18px; }
#toolbar {
  background: var(--panel-2); border: 1px solid var(--border) !important;
  border-radius: 12px 12px 0 0; position: sticky; top: 68px; z-index: 40;
}
#editor {
  background: #fff; border: 1px solid var(--border) !important; border-top: none !important;
  border-radius: 0 0 12px 12px; min-height: 460px; font-size: 1.02em; font-family: inherit;
}
#editor .ql-editor { min-height: 460px; }
.ql-snow .ql-stroke { stroke: var(--text-dim); }
.ql-snow .ql-fill { fill: var(--text-dim); }
.ql-snow .ql-picker { color: var(--text-dim); }
.ql-snow .ql-picker-options { background: var(--panel); border-color: var(--border) !important; }
.ql-snow.ql-toolbar button:hover .ql-stroke, .ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--primary); }
.ql-snow.ql-toolbar button:hover .ql-fill, .ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--primary); }
.ql-editor.ql-blank::before { color: var(--text-dim); font-style: normal; }

.cover-box {
  border: 1px dashed var(--border); border-radius: 10px; overflow: hidden;
  aspect-ratio: 16 / 9; background: var(--panel-2); position: relative;
}
.cover-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: .9em;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border); padding: 26px 0; text-align: center;
  color: var(--text-dim); font-size: .88em; background: #fff;
}
.footer-logo { width: 30px; height: 30px; margin-bottom: 8px; opacity: .85; }

/* ---------- RWD ---------- */
@media (max-width: 900px) {
  .two-col, .editor-layout { grid-template-columns: 1fr; }
  .editor-side { order: -1; }
}
@media (max-width: 640px) {
  .header-inner { gap: 12px; }
  .main-nav { order: 3; width: 100%; justify-content: center; }
  .search-form { display: none; }
  .coll-item { flex-direction: column; }
  .coll-item-side { flex-direction: row; align-items: center; }
}
