/* TsERP 系統資訊 — 對外資訊網
 * 設計原則：資訊清楚 > 好搜尋 > 載入快 > 視覺整潔。無花俏動畫。
 */

:root {
  --c-text: #1f2937;
  --c-text-muted: #6b7280;
  --c-text-light: #9ca3af;
  --c-border: #e5e7eb;
  --c-border-strong: #d1d5db;
  --c-bg: #ffffff;
  --c-bg-alt: #f9fafb;
  --c-bg-hover: #f3f4f6;
  --c-primary: #4f46e5;
  --c-primary-hover: #4338ca;
  --c-primary-light: #eef2ff;
  --c-green: #16a34a;
  --c-amber: #d97706;
  --c-red: #dc2626;
  --c-gray: #6b7280;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Microsoft JhengHei', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ===== Header ===== */

.site-header {
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  font-weight: 600;
  font-size: 16px;
  color: var(--c-text);
  text-decoration: none;
}
.site-header nav {
  display: flex;
  gap: 4px;
  font-size: 14px;
}
.site-header nav a {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--c-text-muted);
  text-decoration: none;
}
.site-header nav a:hover {
  background: var(--c-bg-hover);
  color: var(--c-text);
}
.site-header nav a.active {
  background: var(--c-primary-light);
  color: var(--c-primary);
}

/* ===== Main ===== */

main {
  padding: 32px 16px 64px;
  min-height: calc(100vh - 130px);
}

h1 { font-size: 28px; margin: 0 0 8px; font-weight: 700; }
h2 { font-size: 20px; margin: 32px 0 16px; font-weight: 600; }
h3 { font-size: 16px; margin: 24px 0 12px; font-weight: 600; }
.page-intro { color: var(--c-text-muted); margin: 0 0 24px; }

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: 'Cascadia Code', 'Consolas', monospace;
  background: var(--c-bg-alt);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 13px;
}
pre {
  background: var(--c-bg-alt);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 12px;
  overflow-x: auto;
}
pre code { background: transparent; padding: 0; }

/* ===== Hero (homepage) ===== */

.hero { text-align: center; padding: 32px 0 24px; }
.hero h1 { font-size: 36px; margin-bottom: 8px; }
.hero-sub { color: var(--c-text-muted); font-size: 16px; }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 32px 0;
}
.stat-card {
  display: block;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  color: var(--c-text);
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.stat-card:hover { border-color: var(--c-primary); text-decoration: none; }
.stat-icon { font-size: 32px; }
.stat-label { font-size: 14px; color: var(--c-text-muted); margin: 8px 0 4px; }
.stat-value { font-size: 32px; font-weight: 700; }
.stat-value small { font-size: 14px; font-weight: 400; color: var(--c-text-muted); margin-left: 4px; }
.stat-sub { font-size: 12px; color: var(--c-text-light); margin-top: 4px; }

.dual-list { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.dual-list h2 { margin-top: 0; }
.news-list { list-style: none; padding: 0; margin: 0; }
.news-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  gap: 12px;
  align-items: baseline;
}
.news-list .news-date {
  color: var(--c-text-light);
  font-family: 'Cascadia Code', monospace;
  font-size: 12px;
  white-space: nowrap;
}
.news-list a { flex: 1; color: var(--c-text); }
.news-list a:hover { color: var(--c-primary); text-decoration: none; }
.more-link { text-align: right; margin: 12px 0 0; }

/* ===== Controls (system-map) ===== */

.controls {
  background: var(--c-bg-alt);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
}
#search-input {
  flex: 1;
  min-width: 200px;
  padding: 6px 10px;
  border: 1px solid var(--c-border-strong);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
#search-input:focus { outline: 2px solid var(--c-primary); outline-offset: -1px; border-color: var(--c-primary); }
.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--c-text-muted);
}
.control-group select {
  padding: 5px 8px;
  border: 1px solid var(--c-border-strong);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  background: white;
}
.count { font-size: 13px; color: var(--c-text-muted); }
.count strong { color: var(--c-text); }
.btn-text {
  background: transparent;
  border: none;
  color: var(--c-primary);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.btn-text:hover { text-decoration: underline; }

/* ===== System-map table ===== */

.sm-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}
.sm-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--c-bg-alt);
  border-bottom: 1px solid var(--c-border-strong);
  font-weight: 600;
  font-size: 13px;
  color: var(--c-text-muted);
}
.sm-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: top;
}
.sm-table tbody tr:nth-child(even) { background: var(--c-bg-alt); }
.sm-table tbody tr:hover { background: var(--c-bg-hover); }
.sm-table .col-sub { width: 130px; }
.sm-table .col-prog { width: 28%; }
.sm-table .col-feat { }
.sm-table .col-status { width: 100px; }

.prog-cell { display: flex; align-items: baseline; gap: 8px; }
.prog-cell a {
  color: var(--c-text);
  font-weight: 500;
  text-decoration: none;
}
.prog-cell a:hover { color: var(--c-primary); }
.prog-cell .ext { color: var(--c-text-light); font-size: 11px; }
.prog-ids { font-family: 'Cascadia Code', 'Consolas', monospace; font-size: 13px; color: var(--c-primary); }
.prog-name { color: var(--c-text); }

.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* subsystem chips — indigo 階梯 */
.chip-sub-A-System { background: #eef2ff; color: #4338ca; }
.chip-sub-B-BasicData { background: #e0e7ff; color: #4338ca; }
.chip-sub-C-GeneralAffair { background: #c7d2fe; color: #3730a3; }
.chip-sub-D-Bom { background: #a5b4fc; color: #1e1b4b; }
.chip-sub-E-SalesOrder { background: #818cf8; color: #1e1b4b; }
.chip-sub-F-Production { background: #c7d2fe; color: #3730a3; }
.chip-sub-G-Purchasing { background: #a5b4fc; color: #1e1b4b; }
.chip-sub-H-Inventory { background: #818cf8; color: #ffffff; }
.chip-sub-I-ARAP { background: #6366f1; color: #ffffff; }
.chip-sub-J-Quality { background: #e0e7ff; color: #4338ca; }
.chip-sub-K-Cost { background: #c7d2fe; color: #3730a3; }
.chip-sub-L-Communication { background: #ddd6fe; color: #5b21b6; }
.chip-sub-M-EIS { background: #c4b5fd; color: #4c1d95; }
.chip-sub-N-GeneralLedger { background: #a78bfa; color: #ffffff; }
.chip-sub-O-Check { background: #8b5cf6; color: #ffffff; }
.chip-sub-P-Invoice { background: #ddd6fe; color: #5b21b6; }
.chip-sub-Q-FixedAsset { background: #c4b5fd; color: #4c1d95; }
.chip-sub-R-HumanResource { background: #a78bfa; color: #ffffff; }

.feat-cell { color: var(--c-text); }
.feat-cell .feat-empty { color: var(--c-text-light); }
.feat-cell .feat-plus { color: var(--c-text-muted); margin-left: 4px; font-size: 12px; }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.status-stable { color: var(--c-green); }
.status-stable .status-dot { background: var(--c-green); }
.status-beta { color: var(--c-amber); }
.status-beta .status-dot { background: var(--c-amber); }
.status-deprecated { color: var(--c-gray); }
.status-deprecated .status-dot { background: var(--c-gray); }

.empty-state {
  background: var(--c-bg-alt);
  border: 1px dashed var(--c-border-strong);
  border-radius: 8px;
  padding: 48px 16px;
  text-align: center;
  margin-top: 24px;
}
.empty-state p { margin: 8px 0; color: var(--c-text-muted); }
.btn {
  background: var(--c-primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover { background: var(--c-primary-hover); }

/* ===== Changelog ===== */

.cl-month { margin: 32px 0 16px; }
.cl-month h2 { margin-bottom: 12px; }
.cl-month .cl-count { color: var(--c-text-light); font-weight: 400; font-size: 14px; }
.cl-list { list-style: none; padding: 0; margin: 0; }
.cl-entry {
  border: 1px solid var(--c-border);
  border-radius: 8px;
  margin-bottom: 12px;
  background: white;
}
.cl-entry-head {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  gap: 12px;
  align-items: center;
}
.cl-entry-head:hover { background: var(--c-bg-hover); }
.cl-date {
  font-family: 'Cascadia Code', monospace;
  font-size: 13px;
  color: var(--c-text-light);
  white-space: nowrap;
}
.cl-title { flex: 1; font-weight: 500; }
.cl-tags { display: flex; gap: 4px; }
.cl-tag { font-size: 11px; padding: 2px 6px; border-radius: 4px; font-weight: 500; }
.cl-tag-新增 { background: #dcfce7; color: #15803d; }
.cl-tag-變更 { background: #dbeafe; color: #1d4ed8; }
.cl-tag-刪除 { background: #fed7aa; color: #c2410c; }
.cl-tag-Breaking { background: #fecaca; color: #b91c1c; }
.cl-arrow { color: var(--c-text-light); transition: transform 0.15s; }
.cl-entry.open .cl-arrow { transform: rotate(90deg); }
.cl-body {
  padding: 0 16px 16px;
  display: none;
  border-top: 1px solid var(--c-border);
}
.cl-entry.open .cl-body { display: block; }
.cl-body h2 { font-size: 18px; margin: 16px 0 8px; }
.cl-body h3 { font-size: 15px; margin: 12px 0 8px; }
.cl-body p { margin: 8px 0; }
.cl-body ul { margin: 8px 0; padding-left: 20px; }
.cl-body table { border-collapse: collapse; margin: 12px 0; }
.cl-body th, .cl-body td { border: 1px solid var(--c-border); padding: 6px 10px; text-align: left; }

/* ===== SQL ===== */

.sql-list { display: flex; flex-direction: column; gap: 16px; }
.sql-card {
  border: 1px solid var(--c-border);
  border-radius: 8px;
  background: white;
  padding: 16px;
}
.sql-card-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.sql-card-date {
  font-family: 'Cascadia Code', monospace;
  color: var(--c-text-light);
  font-size: 13px;
}
.sql-card-title { font-weight: 600; flex: 1; }
.sql-card-objs { margin: 8px 0 12px; display: flex; flex-wrap: wrap; gap: 4px; }
.sql-obj {
  font-family: 'Cascadia Code', monospace;
  font-size: 12px;
  padding: 2px 8px;
  background: var(--c-primary-light);
  color: var(--c-primary);
  border-radius: 4px;
}
.sql-card pre { font-size: 12px; max-height: 360px; overflow-y: auto; }
.copy-btn {
  background: white;
  border: 1px solid var(--c-border-strong);
  border-radius: 6px;
  padding: 4px 12px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.copy-btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.sql-changelog-link {
  display: block;
  margin-top: 12px;
  color: var(--c-text-muted);
  font-size: 13px;
}

/* ===== Footer ===== */

.site-footer {
  border-top: 1px solid var(--c-border);
  padding: 16px 0;
  text-align: center;
  color: var(--c-text-light);
  font-size: 12px;
}
.site-footer .sep { margin: 0 8px; }

/* ===== RWD ===== */

@media (max-width: 768px) {
  .container { padding: 0 12px; }
  .stat-cards { grid-template-columns: 1fr; }
  .dual-list { grid-template-columns: 1fr; }
  .site-header .container { flex-direction: column; align-items: flex-start; gap: 8px; }
  .control-row { flex-direction: column; align-items: stretch; }
  #search-input { width: 100%; }

  /* 表格 → 卡片式 */
  .sm-table thead { display: none; }
  .sm-table, .sm-table tbody, .sm-table tr, .sm-table td { display: block; width: 100%; }
  .sm-table tr {
    border: 1px solid var(--c-border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    background: white !important;
  }
  .sm-table td { border: none; padding: 4px 0; }
  .sm-table td::before { content: attr(data-label) ': '; color: var(--c-text-muted); font-size: 12px; }
}
