/* ===================================================================
   Win7 外觀層（基於 7.css，只做佈局與少量補充，不覆蓋 7.css 組件樣式）
   =================================================================== */

:root {
  --ink: #1a1a1a;
  --ink-2: #444;
  --ink-3: #6d6d6d;
  --line: #a0a0a0;
  --line-2: #c8c8c8;
  --ok: #107c10;
  --danger: #b81d1d;
  --accent: #1f5fbf;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: "Segoe UI", "Microsoft JhengHei", "Microsoft YaHei", Tahoma, sans-serif;
  font-size: 13px;
  color: var(--ink);
  background: linear-gradient(180deg, #0b4a72 0%, #1b6ea8 45%, #7fb0cf 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

a { color: #0b4d9b; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; }

.hidden { display: none !important; }
.muted { color: var(--ink-3); }
.mono { font-family: Consolas, "Courier New", monospace; }

/* ---------- 通用：窗口內容 ---------- */
.w7-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.window-body { font-size: 13px; }

/* 標題列文字發光在淺底上會看不清，這裡保留 7.css 默認 */
.title-bar { user-select: none; }

/* ---------- 表單補充 ---------- */
.field { margin-bottom: 12px; }
.field > label {
  display: block;
  margin-bottom: 4px;
  color: var(--ink-2);
}
.field .req { color: var(--danger); margin-left: 2px; }

.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
}

textarea { font-family: Consolas, "Courier New", monospace; font-size: 12px; }

.hint { margin: 4px 0 0; font-size: 11px; color: var(--ink-3); line-height: 1.5; }
.hint.error { color: var(--danger); }

.input-group {
  display: flex;
  align-items: stretch;
}
.input-group input { flex: 1; min-width: 0; }
.input-group .addon {
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: #f0f0f0;
  border: 1px solid #a0a0a0;
  border-left: 0;
  font-family: Consolas, monospace;
  color: #333;
  white-space: nowrap;
}

.alert {
  padding: 8px 10px;
  margin-bottom: 10px;
  border: 1px solid #d5b48a;
  background: #fffbe6;
  color: #6b4b00;
  font-size: 12px;
}
.alert.error { border-color: #e0a0a0; background: #fff0f0; color: #8b1a1a; }
.alert.ok { border-color: #a6d3a6; background: #f0faf0; color: #10610f; }
.alert.hidden { display: none; }

/* ---------- 後綴選擇：做成按鈕組 ---------- */
.suffix-list { display: flex; flex-wrap: wrap; gap: 6px; }

.suffix-opt {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  border: 1px solid #8e8f8f;
  border-radius: 3px;
  background: linear-gradient(#fdfdfd, #e4e4e4);
  font-family: Consolas, monospace;
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
}
.suffix-opt:hover { background: linear-gradient(#f4fbff, #cbe6fb); border-color: #4a9bd8; }
.suffix-opt input { position: absolute; opacity: 0; pointer-events: none; }
.suffix-opt.checked {
  background: linear-gradient(#d7ecfb, #b6dcf7);
  border-color: #2a7fc1;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
  font-weight: 700;
}
.suffix-opt .tag { font-family: inherit; font-size: 10.5px; color: var(--danger); font-weight: 400; }

/* ---------- 驗證碼 ---------- */
.captcha-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.captcha-q {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 12px;
  border: 1px solid #a0a0a0;
  background: #fff;
  font-family: Consolas, monospace;
  font-size: 14px;
  letter-spacing: 1px;
  box-shadow: inset 1px 1px 0 #d8d8d8;
  user-select: none;
  white-space: nowrap;
}
.captcha-row input[type="text"] { width: 80px; text-align: center; }
.spacer { flex: 1; }

.form-terms {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--ink-3);
  text-align: center;
  line-height: 1.6;
}

/* ---------- 註冊頁 ---------- */
.pub-window { width: min(560px, calc(100vw - 24px)); }
.pub-window .window-body { padding: 14px 16px 6px; }

.hero { text-align: center; margin: 2px 0 14px; }
.hero h1 { font-size: 18px; }
.hero p { margin: 4px 0 0; font-size: 12px; color: var(--ink-2); }

fieldset { margin: 12px; }
fieldset:first-of-type { margin-top: 12px; }

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin: 14px 12px 12px;
}
.dialog-buttons button { min-width: 88px; }

/* 成功面板 */
.success { text-align: center; }
.success-icon {
  width: 44px; height: 44px;
  margin: 4px auto 10px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: #e8f6e8;
  border: 1px solid #9ccf9c;
  color: var(--ok);
}
.success h2 { font-size: 15px; }
.success p { margin: 6px 0 0; font-size: 12px; color: var(--ink-2); }

.email-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #a0a0a0;
  box-shadow: inset 1px 1px 0 #d8d8d8;
  font-family: Consolas, monospace;
  font-size: 13.5px;
  word-break: break-all;
}
.email-box span { flex: 1; text-align: left; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 12px; }
.kv span:first-child { color: var(--ink-3); }
.kv span:last-child { font-family: Consolas, monospace; }

.success-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.success-actions .btn-like { text-decoration: none; }

/* ---------- 後台 ---------- */
.admin-body { padding: 8px; }

.app-window {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 16px);
  min-height: 420px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: linear-gradient(#fbfcfe, #eef2f7);
  border-bottom: 1px solid #c4c4c4;
  flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }
.toolbar .title-hint { font-size: 12px; color: var(--ink-3); margin-left: auto; }

.main-area {
  flex: 1;
  display: flex;
  min-height: 0;
  background: #fff;
}

/* 左側導覽（Win7 巡覽窗格） */
.pane {
  width: 148px;
  flex: 0 0 148px;
  padding: 8px;
  background: linear-gradient(#f7f9fc, #edf1f6);
  border-right: 1px solid #c8c8c8;
  overflow-y: auto;
}
.pane-title {
  font-size: 11px;
  color: #6b6b6b;
  padding: 2px 4px 6px;
  border-bottom: 1px solid #dcdcdc;
  margin-bottom: 6px;
}
.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 5px 8px;
  margin-bottom: 2px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: none;
  font: inherit;
  font-size: 12.5px;
  color: #123a63;
  cursor: pointer;
}
.nav-item:hover { background: #e3f1fd; border-color: #b7dcf7; }
.nav-item.active {
  background: linear-gradient(#dbeefc, #bfe1f8);
  border-color: #8fc4e8;
  font-weight: 600;
}
.pane-foot {
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px solid #dcdcdc;
  font-size: 10.5px;
  color: #777;
  line-height: 1.6;
}

/* 內容區 */
.content {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 12px 14px 18px;
  background: #fff;
}

.page-head { margin-bottom: 12px; }
.page-head h1 { font-size: 15px; }
.page-head p { margin: 3px 0 0; font-size: 11.5px; color: var(--ink-3); }

/* 統計卡 */
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.stat {
  flex: 1 1 140px;
  padding: 8px 10px;
  background: linear-gradient(#fdfefe, #f1f5f9);
  border: 1px solid #b8b8b8;
  border-radius: 3px;
}
.stat .label { font-size: 11px; color: var(--ink-3); }
.stat .value { font-size: 22px; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.stat .meta { font-size: 10.5px; color: var(--ink-3); }

/* 面板 */
.panel {
  border: 1px solid #b8b8b8;
  border-radius: 3px;
  background: #fff;
  margin-bottom: 12px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  background: linear-gradient(#fafcfe, #eaf0f6);
  border-bottom: 1px solid #d2d2d2;
  flex-wrap: wrap;
}
.panel-head h2 { font-size: 13px; }
.panel-head p { margin: 2px 0 0; font-size: 11px; color: var(--ink-3); }
.panel-body { padding: 10px 12px; }

/* 表格（覆蓋 7.css 的 fixed 佈局，保證長文本可讀） */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  table-layout: auto;
  white-space: normal;
  border-collapse: collapse;
  font-size: 12.5px;
}
table.data th {
  text-align: left;
  font-weight: 400;
  font-size: 11.5px;
  color: #333;
  background: linear-gradient(#fefefe, #eef1f5);
  padding: 6px 10px;
  border-right: 1px solid #dcdcdc;
  border-bottom: 1px solid #c8c8c8;
  white-space: nowrap;
  position: static;
}
table.data td {
  padding: 6px 10px;
  border-bottom: 1px solid #ededed;
  vertical-align: middle;
}
table.data tbody tr:nth-child(even) { background: #fafbfc; }
table.data tbody tr:hover { background: #eaf4fd; }
table.data .actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
table.data .actions button { min-width: 0; padding: 2px 8px; }

.empty { padding: 22px; text-align: center; color: var(--ink-3); font-size: 12px; }

/* 小標籤 */
.badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: 11px;
  border: 1px solid #b9b9b9;
  border-radius: 2px;
  background: #f2f2f2;
  color: #444;
  white-space: nowrap;
}
.badge.ok { background: #eaf7ea; border-color: #9ed09e; color: #14651a; }
.badge.warn { background: #fff6e0; border-color: #dfc081; color: #7a5200; }
.badge.danger { background: #fdeeee; border-color: #dfa3a3; color: #8b1a1a; }
.badge.dot::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 4px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: 1px;
}

/* 兩列表單 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* 開關（Win7 沒有，用勾選框代替時這裡做個兼容） */
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.switch input { margin: 0; }
.switch .track { display: none; }

/* 對話框 */
dialog.modal {
  border: 0;
  padding: 0;
  background: transparent;
  width: min(680px, calc(100vw - 20px));
  max-height: calc(100vh - 40px);
  color: var(--ink);
}
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.42); }
.modal-window { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.modal-window .window-body { padding: 10px 12px; overflow: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 12px;
  background: #f2f4f7;
  border-top: 1px solid #d0d0d0;
}
.modal-foot button { min-width: 84px; }

details.advanced { margin-top: 8px; border-top: 1px solid #dcdcdc; padding-top: 8px; }
details.advanced summary { cursor: pointer; font-size: 12px; color: #123a63; }
details.advanced[open] summary { margin-bottom: 10px; }

/* 登入窗 */
.login-window { width: min(380px, calc(100vw - 24px)); }
.login-window .window-body { padding: 14px 16px 4px; }
.login-brand { display: flex; align-items: center; gap: 8px; justify-content: center; margin-bottom: 10px; }
.brand-mark {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 4px;
  background: linear-gradient(#2f7fd0, #17539b);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}
.login-title { text-align: center; font-size: 14px; }
.login-sub { text-align: center; font-size: 11.5px; color: var(--ink-3); margin: 4px 0 14px; }

/* 提示条 */
#toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 10px);
  opacity: 0;
  pointer-events: none;
  background: #1f2937;
  color: #fff;
  padding: 7px 14px;
  border-radius: 3px;
  font-size: 12.5px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: opacity 0.18s, transform 0.18s;
  z-index: 90;
  max-width: calc(100vw - 24px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: #8b1a1a; }

/* 讓 <a> 看起來是按鈕（7.css 只處理 button） */
.btn-like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 72px;
  padding: 4px 12px;
  border: 1px solid #8e8f8f;
  border-radius: 3px;
  background: linear-gradient(#fdfdfd, #e4e4e4);
  font-size: 12px;
  color: #1a1a1a;
  text-decoration: none;
  cursor: pointer;
}
.btn-like:hover { background: linear-gradient(#f4fbff, #cbe6fb); border-color: #4a9bd8; }
.btn-like.primary { background: linear-gradient(#e8f4fd, #c3e2fa); border-color: #5c9fd8; }

/* ---------- 響應式 ---------- */
@media (max-width: 860px) {
  .admin-body { padding: 0; }
  .app-window { height: 100vh; border-radius: 0; }
  .app-window > .title-bar { display: none; }
  .main-area { flex-direction: column; }
  .pane {
    width: 100%;
    flex: none;
    display: flex;
    gap: 4px;
    padding: 6px;
    border-right: 0;
    border-bottom: 1px solid #c8c8c8;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .pane-title, .pane-foot { display: none; }
  .nav-item { width: auto; white-space: nowrap; margin: 0; }
  .content { padding: 10px; }
  .form-grid { grid-template-columns: 1fr; }
  .stats { gap: 6px; }
  .stat { flex: 1 1 45%; }
  table.data th { padding: 5px 8px; }
  table.data td { padding: 6px 8px; }
}

@media (max-width: 560px) {
  .w7-center { padding: 8px; align-items: flex-start; padding-top: 12px; }
  .pub-window { width: calc(100vw - 16px); }
  .pub-window .window-body { padding: 10px 10px 2px; }
  fieldset { margin: 10px 8px; }
  .dialog-buttons { margin: 12px 8px 10px; }
  .field input[type="text"], .field input[type="password"],
  .field input[type="number"], .field select { font-size: 16px; } /* 防 iOS 縮放 */
  .suffix-list { gap: 4px; }
  .suffix-opt { height: 26px; padding: 0 10px; font-size: 12px; }
  .toolbar { padding: 4px 6px; gap: 4px; }
  .toolbar .title-hint { display: none; }
  .content { padding: 8px; }
  .panel-head { padding: 6px 8px; }
  .panel-body { padding: 8px; }
  .panel-head .select, .panel-head .input { flex: 1 1 100%; min-width: 0; }
  .panel-head > div:last-child { width: 100%; flex-wrap: wrap; gap: 4px; }

  /* 後綴表：小屏收起「郵件伺服器 / 累計」列 */
  #view-domains table.data th:nth-child(2),
  #view-domains table.data td:nth-child(2),
  #view-domains table.data th:nth-child(5),
  #view-domains table.data td:nth-child(5) { display: none; }
  /* 記錄表：小屏改為卡片式列表（郵箱在首行，時間/狀態次行，備註末行；隱藏 IP） */
  #view-records .table-wrap { overflow-x: hidden; }
  #view-records table.data,
  #view-records table.data tbody { display: block; }
  #view-records table.data thead { display: none; }
  #view-records table.data tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 7px 4px;
    border-bottom: 1px solid #dcdcdc;
  }
  #view-records table.data tbody tr:last-child { border-bottom: 0; }
  #view-records table.data td {
    display: block;
    border: 0;
    padding: 1px 2px;
    white-space: normal;
    word-break: break-all;
  }
  #view-records table.data td:nth-child(3) { display: none; } /* IP */
  #view-records table.data td:nth-child(2) { order: -1; flex: 1 1 100%; font-size: 13px; } /* 郵箱 */
  #view-records table.data td:nth-child(1) { flex: 1 1 auto; font-size: 11px; color: #6b7280; } /* 時間 */
  #view-records table.data td:nth-child(4) { flex: 0 0 auto; padding: 2px; word-break: normal; } /* 狀態 */
  #view-records table.data td:nth-child(5) { flex: 1 1 100%; font-size: 11px; color: #9a3324; } /* 備註 */
  .modal-window { max-height: calc(100vh - 16px); }
  .modal-foot button { min-width: 72px; }
}

/* 極小屏（≤380px）：後綴表再收起「今日」列，操作按鈕壓縮 */
@media (max-width: 380px) {
  #view-domains table.data th:nth-child(4),
  #view-domains table.data td:nth-child(4) { display: none; }
  table.data .actions button { padding: 2px 5px; font-size: 11px; min-width: 0; }
  .toolbar button, .toolbar .btn { padding: 3px 8px; font-size: 12px; }
}
