/* OpenAccount - 線上開戶系統 */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700;900&display=swap');

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #e2e8f0;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #eff6ff;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --success: #059669;
  --success-bg: #ecfdf5;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 16px rgba(15, 23, 42, 0.06);
  --font: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ===== Header ===== */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo-section { display: flex; align-items: center; gap: 0.65rem; }

.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), #3b82f6);
  color: #fff;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 0.95rem;
}

.logo-text { font-size: 1.1rem; font-weight: 700; }

.top-menu { display: flex; gap: 0.5rem; }

.menu-item {
  display: flex; align-items: center; gap: 0.45rem;
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.menu-item svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.menu-item:hover { background: var(--primary-soft); color: var(--primary); }
.menu-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }

/* ===== Layout ===== */
main { max-width: 1080px; margin: 0 auto; padding: 2.5rem 1.5rem; }

.content-pane { display: none; }
.content-pane.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header { margin-bottom: 1.75rem; }
.page-header h1 { font-size: 1.6rem; font-weight: 900; margin-bottom: 0.3rem; }
.page-header p { color: var(--text-secondary); font-size: 0.92rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.success-title { color: var(--success); border-color: #a7f3d0; }

/* ===== Upload boxes ===== */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 700px) { .upload-grid { grid-template-columns: 1fr; } }

.upload-box {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
  background: #fafbfd;
}

.upload-box:hover { border-color: var(--primary); background: var(--primary-soft); }
.upload-box.has-image { border-style: solid; border-color: var(--primary); cursor: default; background: #fff; }

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1.5rem;
  text-align: center;
}

.upload-placeholder svg { width: 44px; height: 44px; stroke: var(--text-muted); fill: none; stroke-width: 1.5; margin-bottom: 0.4rem; }
.upload-placeholder strong { font-size: 1rem; }
.upload-placeholder span { font-size: 0.8rem; color: var(--text-muted); }

.upload-preview { width: 100%; max-height: 260px; object-fit: contain; display: block; }

.btn-remove-img {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  border: none;
  font-family: var(--font);
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
}
.btn-remove-img:hover { background: var(--danger); }

/* ===== Form ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}

@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--text-secondary);
}

.form-group label em { color: var(--danger); font-style: normal; }

.form-control {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

/* ===== Buttons ===== */
.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 700;
  padding: 0.65rem 1.4rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: #fff; border: 1px solid var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary { background: #fff; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--text-muted); color: var(--text); }

.btn-primary svg, .btn-secondary svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }

.btn-submit { width: 100%; justify-content: center; font-size: 1rem; padding: 0.85rem; }

/* ===== 清單 ===== */
.list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.list-count { font-size: 0.9rem; color: var(--text-secondary); font-weight: 500; }
.toolbar-actions { display: flex; gap: 0.6rem; }

.table-wrapper { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }

table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.88rem; }

thead { background: #f8fafc; }

th {
  padding: 0.8rem 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.8rem;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

td { padding: 0.8rem 1rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; transition: background 0.15s; }
tbody tr:hover { background: var(--primary-soft); }

.empty-placeholder { text-align: center; padding: 3rem; color: var(--text-muted); font-size: 0.9rem; }

.badge { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.badge.ok { background: var(--success-bg); color: var(--success); }
.badge.failed { background: var(--danger-bg); color: var(--danger); }

/* ===== 細節 Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.show { opacity: 1; pointer-events: auto; }

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 760px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.3);
  transform: scale(0.96);
  transition: transform 0.2s;
}

.modal-overlay.show .modal-box { transform: scale(1); }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}

.modal-title { font-size: 1.05rem; font-weight: 700; }

.btn-modal-close {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}
.btn-modal-close:hover { background: var(--danger-bg); color: var(--danger); }

.modal-body { padding: 1.5rem; }

.detail-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 600px) { .detail-images { grid-template-columns: 1fr; } }

.detail-images figure {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #f8fafc;
}

.detail-images img { width: 100%; display: block; object-fit: contain; max-height: 240px; }

/* ===== 圖片放大鏡 (3x) ===== */
.zoom-hint {
  font-size: 0.82rem;
  color: var(--text-secondary);
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  margin-bottom: 1rem;
}

.zoom-wrap {
  position: relative;
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
}

.zoom-lens {
  position: absolute;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.35), inset 0 0 4px rgba(255, 255, 255, 0.5);
  background-repeat: no-repeat;
  background-color: #fff;
  pointer-events: none;
  display: none;
  z-index: 5;
}

.zoom-wrap.zooming .zoom-lens { display: block; }

/* ===== 彈窗內編輯表單 ===== */
.edit-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 1.25rem;
}

@media (max-width: 600px) { .edit-grid { grid-template-columns: 1fr; } }

.edit-grid .edit-full { grid-column: 1 / -1; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.7rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--surface);
}

.edit-meta {
  margin-right: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.detail-images figcaption {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding: 0.5rem;
  border-top: 1px solid var(--border);
  font-weight: 500;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 1.5rem;
}

@media (max-width: 600px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-item { padding: 0.7rem 0.9rem; background: #f8fafc; border-radius: 8px; border: 1px solid var(--border); }
.detail-item.full { grid-column: 1 / -1; }
.detail-item dt { font-size: 0.72rem; color: var(--text-muted); font-weight: 700; margin-bottom: 0.2rem; }
.detail-item dd { font-size: 0.95rem; font-weight: 500; word-break: break-all; }

.result-card .btn-secondary { margin-top: 1.5rem; }

/* ===== Loading overlay ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.loading-overlay.show { display: flex; }
.loading-overlay p { font-weight: 700; color: var(--primary); }

.spinner {
  width: 42px; height: 42px;
  border: 4px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 300;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 0.85rem 1.1rem;
  font-size: 0.88rem;
  font-weight: 500;
  min-width: 260px;
  max-width: 380px;
  animation: slideIn 0.25s ease;
  border-left: 4px solid var(--primary);
}

.toast.success { border-left-color: var(--success); }
.toast.danger { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.hide { opacity: 0; transition: opacity 0.3s; }

/* Responsive header */
@media (max-width: 640px) {
  header { flex-wrap: wrap; height: auto; padding: 0.6rem 1rem; gap: 0.4rem; }
  .top-menu { width: 100%; }
  main { padding: 1.5rem 1rem; }
  .card { padding: 1.25rem; }
}
