@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg: #11151e;
  --card-bg: #18202d;
  --card-bg-hover: #1f2a3c;
  --gold-accent: #dfb76c;
  --gold-glow: rgba(223, 183, 108, 0.25);
  --text-main: #f0f3f8;
  --text-sub: #8a96a8;
  --border: rgba(255, 255, 255, 0.08);
  --border-gold: rgba(223, 183, 108, 0.3);
  --radius-lg: 14px;
  --radius-md: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  margin: 0;
  padding: 10px 10px;
  background: var(--bg);
  color: var(--text-main);
  max-width: 620px;
  margin-left: auto;
  margin-right: auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 統一所有 Input / Textarea 為白底黑字 */
input[type="text"],
input[type="number"],
textarea {
  background-color: #ffffff !important;
  color: #000000 !important;
  border: 1px solid var(--border-gold);
}

input::placeholder,
textarea::placeholder {
  color: #666666 !important;
  opacity: 1;
}

/* Header 區域 */
.app-header {
  position: relative;
  text-align: left;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header-title-group {
  display: flex;
  flex-direction: column;
}

.app-header h1 {
  font-family: 'Cinzel', serif;
  font-size: 20px;
  margin: 0;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--gold-accent);
  text-transform: uppercase;
}

.app-header p.subtitle {
  margin: 3px 0 0 0;
  font-size: 11px;
  color: var(--text-sub);
  letter-spacing: 0.5px;
}

/* Help 按鈕 */
.help-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-gold);
  background: var(--card-bg);
  color: var(--gold-accent);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.help-btn:hover, .help-btn:active {
  background: var(--gold-accent);
  color: var(--bg);
  box-shadow: 0 0 12px var(--gold-glow);
}

/* Tab 分頁切換器 */
.tab-container {
  display: flex;
  background: #141a24;
  border-radius: var(--radius-lg);
  padding: 3px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  padding: 7px 12px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.tab-btn.active {
  background: var(--card-bg);
  color: var(--gold-accent);
  border: 1px solid var(--border-gold);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* 檔案上傳與貼上區 (緊湊版面，空間極大化) */
#file-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

#drop-zone {
  border: 1px dashed var(--border-gold);
  border-radius: var(--radius-lg);
  padding: 12px;
  text-align: center;
  background: var(--card-bg);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow);
}

#drop-zone.hover, #drop-zone:hover {
  border-color: var(--gold-accent);
  background: var(--card-bg-hover);
  box-shadow: 0 0 15px var(--gold-glow);
}

#drop-zone p {
  margin: 0 0 2px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

#drop-zone small {
  display: block;
  color: var(--text-sub);
  font-size: 11px;
}

#file-input {
  display: none !important;
}

.enc-submit-btn {
  width: 100%;
  padding: 9px;
  background: linear-gradient(135deg, #dfb76c 0%, #b88e40 100%);
  color: #11151e;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 13px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: all 0.25s ease;
  box-shadow: 0 4px 15px var(--gold-glow);
}

.enc-submit-btn:active {
  transform: translateY(1px);
  opacity: 0.9;
}

#paste-section {
  display: none;
  background: var(--card-bg);
  padding: 10px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

#paste-input {
  width: 100%;
  height: 70px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: 13px;
  resize: none;
  outline: none;
}

#file-badge {
  display: none;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  padding: 4px 12px;
  border-radius: 20px;
  margin-top: 4px;
  border: 1px solid var(--border-gold);
  width: fit-content;
}

#file-name-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--gold-accent);
}

/* 列號設定 */
.row-settings {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 6px;
  background: var(--card-bg);
  padding: 8px 10px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.row-setting-item label {
  font-size: 10px;
  color: var(--text-sub);
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.row-setting-item input {
  width: 100%;
  height: 32px;
  padding: 4px 8px;
  font-size: 13px;
  border-radius: var(--radius-md);
  text-align: center;
  outline: none;
  font-weight: 700;
}

#btn-reparse {
  padding: 0 14px;
  background: var(--gold-accent);
  color: #11151e;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  height: 32px;
  transition: all 0.2s ease;
}

#btn-reparse:active {
  background: #cba255;
}

/* 檢視器 (搜尋與分頁同一行) */
#viewer {
  display: none;
  margin-top: 8px;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.controls-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-shrink: 0;
  height: 36px;
  align-items: center;
}

.search-box {
  flex: 1;
  min-width: 0;
  height: 100%;
}

.search-box input {
  width: 100%;
  height: 100%;
  padding: 0 10px;
  border-radius: var(--radius-md);
  outline: none;
  font-size: 12px;
}

/* 單行分頁 Controls */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-bg);
  padding: 0 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  height: 100%;
  flex-shrink: 0;
  gap: 6px;
}

.page-center-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#page-info {
  font-weight: 700;
  font-size: 12px;
  font-family: 'Cinzel', monospace;
  color: var(--gold-accent);
  white-space: nowrap;
}

/* 圖標按鈕 */
.icon-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-gold);
  background: #141a24;
  color: var(--gold-accent);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-btn svg {
  width: 14px;
  height: 14px;
  fill: var(--gold-accent);
  display: block;
}

.icon-btn:active:not(:disabled) {
  background: var(--gold-accent);
  color: #11151e;
}

.icon-btn:active:not(:disabled) svg {
  fill: #11151e;
}

.icon-btn:disabled {
  opacity: 0.25;
  background: #121722;
  border-color: var(--border);
  cursor: not-allowed;
}

.icon-btn:disabled svg {
  fill: var(--text-sub);
}

/* 跳頁輸入框與按鈕 */
.jump-box {
  display: flex;
  align-items: center;
  gap: 2px;
  background: #ffffff;
  padding: 1px 2px 1px 4px;
  border-radius: 6px;
  border: 1px solid var(--border-gold);
}

.jump-box input {
  width: 32px;
  padding: 0;
  border: none !important;
  background: #ffffff !important;
  font-size: 11px;
  font-weight: 700;
  color: #000000 !important;
  text-align: center;
  outline: none;
}

.jump-box input::-webkit-outer-spin-button,
.jump-box input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

.jump-btn {
  width: 22px;
  height: 22px;
  background: var(--gold-accent);
  border: none;
  border-radius: 4px;
  padding: 0;
}

.jump-btn svg {
  width: 11px;
  height: 11px;
  fill: #11151e;
}

/* 資料卡片（緊湊高能展示，顯示更多行） */
#form-container {
  flex: 1;
  overflow-y: auto;
  padding-right: 2px;
}

.field-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.field-card:hover {
  border-color: var(--border-gold);
  background: var(--card-bg-hover);
}

.field-card:active {
  transform: scale(0.99);
}

.field-label {
  font-size: 11px;
  color: var(--gold-accent);
  font-weight: 700;
  letter-spacing: 0.5px;
  width: 36%;
  word-break: break-word;
}

.field-value {
  font-size: 12px;
  color: var(--text-main);
  width: 64%;
  text-align: right;
  word-break: break-all;
  white-space: pre-wrap;
  line-height: 1.3;
}

.field-value.is-empty {
  color: var(--text-sub);
  opacity: 0.4;
}

/* Modal 彈窗樣式 (預設隱藏) */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 13, 19, 0.85);
  backdrop-filter: blur(8px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-content {
  background: var(--card-bg);
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 16px;
  font-family: 'Cinzel', serif;
  color: var(--gold-accent);
  letter-spacing: 1px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--text-sub);
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-main);
}

.modal-body h3 {
  font-size: 14px;
  margin: 16px 0 6px 0;
  color: var(--gold-accent);
}

.modal-body h3:first-child {
  margin-top: 0;
}

.modal-body ul, .modal-body ol {
  margin: 0;
  padding-left: 20px;
}

.modal-body li {
  margin-bottom: 6px;
}

/* Toast 通知 (預設隱藏) */
#toast {
  visibility: hidden;
  min-width: 160px;
  background: var(--gold-accent);
  color: #11151e;
  text-align: center;
  border-radius: 30px;
  padding: 10px 18px;
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 1000;
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}

#toast.show {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
