/* AmBank Form Filler V2 — Styles */

:root {
  --bg: #f5f3f0;
  --surface: #ffffff;
  --border: #d9d6d1;
  --text: #2d2a26;
  --text-muted: #78746d;
  --accent: #1a5f8a;
  --accent-hover: #134b6f;
  --success: #2a7d4f;
  --warning: #b06d0f;
  --danger: #b33a3a;
  --info: #4a7da8;
  --status-auto: #d4edda;
  --status-auto-text: #2a7d4f;
  --status-manual: #fff3cd;
  --status-manual-text: #b06d0f;
  --status-blank: #f0efed;
  --status-blank-text: #78746d;
  --status-review: #fde3c2;
  --status-review-text: #b06d0f;
  --status-office: #f8d7da;
  --status-office-text: #b33a3a;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

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

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

/* Layout */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

.app-header h1 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.app-header > p {
  flex: 1;
  min-width: 200px;
  margin: 0;
}

.app-header .badge {
  font-size: 0.75rem;
  background: var(--bg);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.app-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* Screens */
.screen { display: none; }
.screen.active { display: block; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card-header {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header .section-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}

/* Textarea */
textarea.input-large {
  width: 100%;
  min-height: 300px;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.7;
  resize: vertical;
  background: #fafaf9;
  color: var(--text);
  transition: border-color 0.15s;
}

textarea.input-large:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

textarea::placeholder {
  color: #b8b4ad;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover { background: #f0efed; border-color: #c0bdb8; }
.btn:active { background: #e6e4e1; }

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.btn-success:hover { background: #236b42; border-color: #236b42; }

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
}

.btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* Form fields */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font);
  color: var(--text);
  background: #fafaf9;
  transition: border-color 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.form-input:disabled {
  background: #f0efed;
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

/* Field status indicators */
.field-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
}

.status-auto { background: var(--status-auto); color: var(--status-auto-text); }
.status-manual { background: var(--status-manual); color: var(--status-manual-text); }
.status-blank { background: var(--status-blank); color: var(--status-blank-text); }
.status-review { background: var(--status-review); color: var(--status-review-text); }
.status-office { background: var(--status-office); color: var(--status-office-text); }

/* Table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  background: #f8f7f5;
  border-bottom: 2px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  white-space: nowrap;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:hover { background: #fafaf9; }

tbody tr.office-row {
  opacity: 0.5;
  background: #fdf5f5;
}

td.value-cell {
  font-family: var(--mono);
  font-size: 0.82rem;
  max-width: 220px;
  word-break: break-all;
}

td.key-cell {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Warnings */
.warning-banner {
  background: #fff9ed;
  border: 1px solid #f0c878;
  border-left: 4px solid var(--warning);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: #7a4e0a;
}

.info-banner {
  background: #edf5fa;
  border: 1px solid #b8d4e8;
  border-left: 4px solid var(--info);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.85rem;
}

/* Unmapped section */
.unmapped-list {
  list-style: none;
}

.unmapped-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: 0.85rem;
}

.unmapped-list .unmapped-label {
  color: var(--text-muted);
  font-weight: 500;
  min-width: 140px;
}

.unmapped-list .unmapped-value {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.82rem;
}

/* Summary */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.summary-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.summary-item .count {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.summary-item .count.warn { color: var(--warning); }
.summary-item .count.office { color: var(--danger); }

.summary-item .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Download area */
.download-card {
  text-align: center;
  padding: 40px 24px;
}

.download-card .check-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--success);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 16px;
}

.download-card h2 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.download-card p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.download-links {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Debug toggle */
.debug-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.debug-toggle input { accent-color: var(--accent); }

.debug-name {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* Progress indicator */
.progress-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
}

.progress-step {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  transition: background 0.3s;
}

.progress-step.done { background: var(--accent); }
.progress-step.current { background: var(--info); }

/* Section fold */
.section-toggle {
  cursor: pointer;
  user-select: none;
}

.section-toggle:hover { color: var(--accent); }

.hidden { display: none; }

/* Key details section (structured inputs above textarea) */
.key-details-section {
  background: #f8faf9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.key-details-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 12px;
}

.key-details-label.secondary-label {
  color: var(--text-muted);
  margin-bottom: 8px;
  margin-top: 0;
}

/* Progress labels below bar */
.progress-labels span.current-label {
  color: var(--accent);
  font-weight: 600;
}

/* Wider value column in mapping table */
td.value-cell {
  max-width: 260px;
  word-break: break-word;
}

/* Responsive */
@media (max-width: 640px) {
  .app-header { padding: 12px 16px; }
  .app-header h1 { font-size: 1rem; }
  .app-main { padding: 16px 12px 40px; }
  .card { padding: 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
