/* ============================
   設計圖文本審校工具 — Web 界面
   ============================ */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f5f6fa;
    --card-bg: #ffffff;
    --text: #2d3436;
    --text-secondary: #636e72;
    --primary: #0984e3;
    --primary-hover: #0767b3;
    --danger: #e74c3c;
    --warning: #f39c12;
    --success: #27ae60;
    --border: #dfe6e9;
    --radius: 10px;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Header ---- */
.header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
}
.logo {
    font-size: 20px;
    font-weight: 700;
    text-decoration: none;
    color: var(--primary);
}
.tagline {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ---- Main ---- */
.main {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

/* ---- Footer ---- */
.footer {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
}

/* ---- Cards ---- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
    margin-bottom: 20px;
}
.card h2 { font-size: 22px; margin-bottom: 6px; }
.card h3 { font-size: 17px; margin-bottom: 12px; }
.subtitle { color: var(--text-secondary); font-size: 14px; margin-bottom: 20px; }
.subtitle code { background: #e8f0fe; padding: 2px 8px; border-radius: 4px; font-size: 13px; }

/* ---- Alerts ---- */
.alert { padding: 12px 18px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fde8e8; color: var(--danger); border: 1px solid #f8c4c4; }

/* ---- Upload Zone ---- */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 20px;
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--primary);
    background: #f0f6ff;
}
.upload-icon svg { color: var(--text-secondary); }
.upload-text { font-size: 16px; color: var(--text-secondary); margin-top: 12px; }
.upload-text .link { color: var(--primary); text-decoration: underline; cursor: pointer; }

/* ---- Preview ---- */
.preview-section {
    text-align: center;
    margin-bottom: 20px;
}
.preview-section img {
    max-width: 300px;
    max-height: 200px;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.preview-name { font-size: 15px; font-weight: 600; margin-top: 8px; }
.preview-size { font-size: 13px; color: var(--text-secondary); }

/* ---- Mode Select ---- */
.mode-select {
    margin-bottom: 20px;
}
.mode-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.mode-option:hover { border-color: var(--primary); }
.mode-option:has(input:checked) {
    border-color: var(--primary);
    background: #f0f6ff;
}
.mode-option input { margin-top: 3px; }
.mode-label strong { display: block; font-size: 15px; }
.mode-label small { font-size: 12px; color: var(--text-secondary); }

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    padding: 10px 22px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, opacity 0.2s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover:not(:disabled) { background: #f0f6ff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { opacity: 0.85; }
.btn-lg { padding: 14px 36px; font-size: 17px; }

/* ---- Progress Bar ---- */
.progress-bar-large {
    height: 10px;
    background: #e8f0fe;
    border-radius: 5px;
    overflow: hidden;
    margin: 16px 0 8px;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #00cec9);
    border-radius: 5px;
    transition: width 0.5s ease;
    width: 0;
}
.progress-pct { font-size: 28px; font-weight: 700; color: var(--primary); text-align: center; }
.progress-msg { text-align: center; color: var(--text-secondary); font-size: 14px; margin-bottom: 16px; }

.progress-mini { margin-top: 16px; }
.progress-mini .progress-bar { height: 6px; background: #e8f0fe; border-radius: 3px; overflow: hidden; }

/* ---- Steps Indicator ---- */
.steps-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 20px;
}
.step-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.step-dot .dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--border);
    border: 2px solid var(--border);
    transition: all 0.3s;
}
.step-dot.active .dot { background: var(--primary); border-color: var(--primary); }
.step-dot.done .dot { background: var(--success); border-color: var(--success); }
.step-label { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.step-line {
    width: 60px;
    height: 2px;
    background: var(--border);
    margin: 0 4px;
    transition: background 0.3s;
}
.step-line.done { background: var(--success); }

/* ---- Steps Overview (upload page) ---- */
.steps-overview {
    display: flex;
    gap: 20px;
    margin-top: 12px;
}
.step-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    flex: 1;
}
.step-num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}
.step-item p { font-size: 13px; color: var(--text-secondary); }

/* ---- Log Box ---- */
.log-box {
    background: #1e272e;
    color: #dfe6e9;
    font-family: "Consolas", "Courier New", monospace;
    font-size: 13px;
    padding: 14px 18px;
    border-radius: 6px;
    max-height: 240px;
    overflow-y: auto;
    margin-bottom: 16px;
}
.log-line { padding: 2px 0; }

/* ---- Stats Grid ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.stat-item {
    text-align: center;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
}
.stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}
.stat-label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ---- Image Viewer ---- */
.image-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}
.image-header h3 { margin-bottom: 0; }

.image-viewport {
    width: 100%;
    height: 65vh;
    min-height: 400px;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    background: repeating-conic-gradient(#e8e8e8 0% 25%, #f5f5f5 0% 50%) 50% / 20px 20px;
    position: relative;
    cursor: grab;
}
.image-viewport:active { cursor: grabbing; }
.image-viewport img {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    user-select: none;
    -webkit-user-drag: none;
}
.image-hint {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* ---- Zoom Toolbar ---- */
.zoom-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    background: #f0f3f5;
    border-radius: 8px;
    padding: 3px;
}
.zoom-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    line-height: 1;
}
.zoom-btn:hover { background: #e0e4e8; }
.zoom-level {
    min-width: 52px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    padding: 0 4px;
}

/* ---- Suspicious List ---- */
.suspicious-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.suspicious-item {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    border-left: 4px solid var(--danger);
    background: #fff;
}
.suspicious-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.suspicious-num {
    background: var(--danger);
    color: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}
.suspicious-original {
    font-size: 18px;
    font-weight: 700;
    background: #ffeaa7;
    padding: 2px 8px;
    border-radius: 4px;
}
.suspicious-arrow { color: var(--text-secondary); font-size: 16px; }
.suspicious-suspected {
    font-size: 18px;
    font-weight: 700;
    background: #dfe6e9;
    padding: 2px 8px;
    border-radius: 4px;
}
.suspicious-reason { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }
.suspicious-meta { font-size: 12px; color: #b2bec3; margin-top: 4px; }

/* ---- Download Links ---- */
.download-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

/* ---- Actions ---- */
.actions {
    text-align: center;
    margin-top: 12px;
}

/* ---- Badge ---- */
.badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 400;
    padding: 2px 10px;
    border-radius: 12px;
    background: #f0f0f0;
    color: var(--text-secondary);
    margin-left: 8px;
    vertical-align: middle;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .steps-overview { flex-direction: column; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .card { padding: 18px; }
    .upload-zone { padding: 28px 16px; }
}
