/* 共用樣式：色彩、字體、按鈕、表單、對話框、提示訊息 */

:root {
  --navy: #0b3f76;
  --blue: #1e5aa0;
  --cyan: #7dc4e4;
  --gold: #e0912a;
  --gold-dark: #b8701a;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft: #eef5fb;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.06);
  --font: "Inter", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 15px;
}

h1, h2, h3, h4 { line-height: 1.3; margin: 0; }
p { margin: 0; }
a { color: var(--blue); }
img { max-width: 100%; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.error-text { color: var(--danger); }

.ic { width: 1.1em; height: 1.1em; flex: none; vertical-align: -0.15em; }

/* --- 按鈕 --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:focus-visible { outline: 3px solid rgba(30, 90, 160, 0.35); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue); }
.btn-accent { background: var(--gold); color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--gold-dark); }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--blue); }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 0.82rem; }
.btn-lg { min-height: 48px; padding: 0 28px; font-size: 1.02rem; }
.btn-block { width: 100%; }

/* --- 表單 --- */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.field > span { font-weight: 600; }
.field em { color: var(--danger); font-style: normal; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], input[type="tel"], select, textarea {
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  background: #fff;
}
textarea { min-height: 72px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30, 90, 160, 0.15); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--navy); }

/* --- 對話框 --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.55);
}
.modal.open { display: flex; }
.modal-box {
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-box.wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-head h2 { font-size: 1.15rem; color: var(--navy); }
.modal-x { border: 0; background: none; font-size: 1.2rem; cursor: pointer; color: var(--muted); width: 36px; height: 36px; border-radius: 50%; }
.modal-x:hover { background: var(--soft); }
.modal-tip { font-size: 0.88rem; color: var(--muted); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* --- 提示訊息 --- */
.toast {
  position: fixed;
  left: 50%;
  top: 16px;
  transform: translate(-50%, -20px);
  z-index: 100;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  font-size: 0.92rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--danger); }

/* --- 狀態標籤 --- */
.status { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; white-space: nowrap; }
.st-draft { background: #f1f5f9; color: #475569; }
.st-sent { background: #e0f2fe; color: #0369a1; }
.st-viewed { background: #ede9fe; color: #6d28d9; }
.st-signed { background: var(--ok-soft); color: var(--ok); }
.st-expired { background: var(--warn-soft); color: var(--warn); }
.st-void { background: #f1f5f9; color: #94a3b8; text-decoration: line-through; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; background: var(--soft); color: var(--navy); white-space: nowrap; }
.tag-soft { background: #f1f5f9; color: #475569; }
.tag-gold { background: #fdf0dc; color: var(--gold-dark); }
.tag-cat-brand { background: #ede9fe; color: #6d28d9; }
.tag-cat-web { background: #e0f2fe; color: #0369a1; }
.tag-cat-seo { background: #dcfce7; color: #15803d; }
.tag-cat-cis { background: #fdf0dc; color: #b8701a; }
.tag-cat-other { background: #f1f5f9; color: #475569; }

.empty-state { max-width: 520px; margin: 15vh auto; text-align: center; padding: 24px; display: flex; flex-direction: column; gap: 10px; }
.empty-state h1 { color: var(--navy); font-size: 1.4rem; }
.loading { text-align: center; padding: 20vh 16px; color: var(--muted); }

.zoom-overlay { position: fixed; inset: 0; z-index: 80; background: rgba(15, 23, 42, 0.85); display: flex; align-items: center; justify-content: center; padding: 16px; cursor: zoom-out; }
.zoom-overlay figure { margin: 0; max-width: 1100px; max-height: 100%; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.zoom-overlay img { max-height: calc(100vh - 80px); object-fit: contain; background: #fff; border-radius: 8px; }
.zoom-overlay figcaption { color: #fff; font-size: 0.9rem; }
.zoom-close { position: fixed; top: 12px; right: 12px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.15); color: #fff; font-size: 1.3rem; cursor: pointer; }
