/* 澳門 EDI 報關資料整理器 — 主樣式 */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Microsoft JhengHei", "Segoe UI", sans-serif; background: #f0f2f5; color: #333; font-size: 14px; }
header { background: #1a73e8; color: #fff; padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
header h1 { font-size: 20px; }
#status-bar { font-size: 13px; opacity: 0.85; flex: 1; }
.session-badge { font-size: 12px; background: rgba(255,255,255,0.18); padding: 4px 10px; border-radius: 12px; font-family: ui-monospace, Consolas, monospace; white-space: nowrap; }

/* Step Cards */
.step-card { background: #fff; margin: 16px auto; max-width: 1400px; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,0.1); overflow: hidden; }
.step-header { background: #e8f0fe; padding: 10px 20px; display: flex; align-items: center; gap: 10px; }
.step-num { background: #1a73e8; color: #fff; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; }
.step-header h2 { font-size: 16px; color: #1a73e8; }
.step-body { padding: 16px 20px; }
.step-actions { margin-top: 12px; display: flex; gap: 10px; }

/* Buttons */
.btn { padding: 6px 14px; border: none; border-radius: 4px; cursor: pointer; font-size: 13px; transition: opacity 0.2s; }
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #1a73e8; color: #fff; }
.btn-success { background: #34a853; color: #fff; }
.btn-info { background: #1a73e8; color: #fff; }
.btn-warning { background: #f9ab00; color: #333; }
.btn-danger { background: #ea4335; color: #fff; }
.btn-secondary { background: #5f6368; color: #fff; }

/* Upload Zone */
.upload-zone { border: 2px dashed #1a73e8; border-radius: 8px; padding: 30px; text-align: center; margin-bottom: 16px; transition: background 0.2s; }
.upload-zone.drag-over { background: #e8f0fe; }
.upload-zone p { margin-bottom: 10px; color: #5f6368; }

/* Source Files */
.source-file-card { border: 1px solid #e0e0e0; border-radius: 6px; padding: 12px; margin-bottom: 12px; }
.source-file-card h4 { color: #1a73e8; margin-bottom: 8px; }
.role-mapping-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.role-mapping-table th, .role-mapping-table td { border: 1px solid #ddd; padding: 5px 8px; text-align: left; }
.role-mapping-table th { background: #f5f5f5; width: 80px; }
.role-mapping-table select { max-width: 200px; }
.role-mapping-table .add-col { width: 30px; text-align: center; }

/* Constants Bar */
.constants-bar { background: #f9f9f9; padding: 10px; border-radius: 6px; margin-bottom: 12px; display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.constants-bar label { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.constants-bar input, .constants-bar select { padding: 3px 6px; border: 1px solid #ccc; border-radius: 3px; }
.constants-bar .chk-option { background: #e8f5e9; padding: 3px 8px; border-radius: 4px; cursor: pointer; }

/* Toolbar */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.toolbar .filter-label { font-size: 13px; margin-left: auto; display: flex; align-items: center; gap: 4px; }
.toolbar .filter-label select { padding: 4px 6px; border: 1px solid #ccc; border-radius: 3px; }

/* HSCODE 可點擊搜尋儲存格 */
.hscode-search-input { cursor: pointer; background: #f0f7ff; }
.hscode-search-input:focus { cursor: text; background: #fff; }

/* Main Table */
.table-wrap { overflow-x: auto; max-height: 600px; }
table#main-table { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
#main-table th, #main-table td { border: 1px solid #ddd; padding: 4px 6px; white-space: nowrap; }
#main-table td { overflow: hidden; text-overflow: ellipsis; }
#main-table th { background: #1a73e8; color: #fff; position: sticky; top: 0; z-index: 10; }
/* 欄寬拖拽握把:th 右緣 6px 熱區 */
#main-table th .col-resizer { position: absolute; top: 0; right: 0; width: 6px; height: 100%; cursor: col-resize; user-select: none; z-index: 12; }
#main-table th .col-resizer:hover { background: rgba(255,255,255,0.45); }
#main-table tbody tr:hover { background: #f5f5f5; }
#main-table td input, #main-table td select { border: 1px solid transparent; background: transparent; padding: 2px; font-size: 12px; width: 100%; min-width: 40px; }
#main-table td input:focus, #main-table td select:focus { border-color: #1a73e8; background: #fff; }
body.col-resizing { cursor: col-resize !important; user-select: none; }

/* Regulation Highlight */
tr.has-regulation { border-left: 4px solid #ea4335 !important; }
tr.has-regulation td { background: #fce8e6 !important; }
td.reg-marked { color: #ea4335; font-weight: bold; }

/* Missing field highlight */
td.missing { background: #fef7e0 !important; }
td.missing-name { background: #fce8e6 !important; }
td.cell-invalid input { background: #fff3cd !important; border-color: #ffc107; }
td.cell-invalid { background: #fff3cd !important; }

/* Output Options */
.output-options { display: flex; gap: 40px; margin-bottom: 16px; }
.radio-group { display: flex; align-items: center; gap: 12px; }
.radio-group p { font-weight: bold; }
.radio-group label { display: flex; align-items: center; gap: 4px; cursor: pointer; }

/* Modals */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; }
.modal.show { display: flex; align-items: center; justify-content: center; }
.modal-content { background: #fff; border-radius: 8px; width: 500px; max-height: 80vh; overflow: hidden; display: flex; flex-direction: column; }
.modal-large { width: 800px; }
.modal-header { padding: 12px 16px; background: #1a73e8; color: #fff; display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; color: #fff; font-size: 24px; cursor: pointer; line-height: 1; }
.modal-body { padding: 16px; overflow-y: auto; flex: 1; }

/* Logs */
.log-item { border-left: 3px solid #1a73e8; padding: 8px 12px; margin-bottom: 6px; background: #f9f9f9; border-radius: 0 4px 4px 0; }
.log-item .log-time { color: #5f6368; font-size: 12px; }
.log-item .log-action { font-weight: bold; }

/* Toast */
#toast { position: fixed; bottom: 20px; right: 20px; z-index: 2000; }
.toast-msg { background: #333; color: #fff; padding: 10px 20px; border-radius: 4px; margin-top: 5px; animation: fadeIn 0.3s; }
.toast-msg.error { background: #ea4335; }
.toast-msg.success { background: #34a853; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Misc */
.loading { color: #1a73e8; font-style: italic; }
.preview-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
.preview-table th, .preview-table td { border: 1px solid #ddd; padding: 3px 6px; }
.preview-table th { background: #f5f5f5; }
