/* ===================== 基础重置 & 变量 ===================== */
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.07), 0 10px 15px rgba(0,0,0,0.1);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container { max-width: 720px; margin: 0 auto; padding: 0 20px; }

/* ===================== 导航栏 ===================== */
.header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: white;
    padding: 20px 0;
    box-shadow: var(--shadow-lg);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.logo { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.5px; }

.badge {
    background: rgba(255,255,255,0.2);
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    backdrop-filter: blur(4px);
}

/* ===================== 步骤指示器 ===================== */
.steps {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 0 20px;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.step-number {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    background: var(--border);
    color: var(--text-secondary);
    transition: all 0.3s;
}

.step.active .step-number {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 0 4px var(--primary-light);
}

.step.done .step-number {
    background: var(--success);
    color: white;
}

.step-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.step.active .step-label { color: var(--primary); font-weight: 600; }
.step.done .step-label { color: var(--success); }

.step-connector {
    width: 60px; height: 2px;
    background: var(--border);
    margin: 0 4px;
    margin-bottom: 24px;
    transition: background 0.3s;
}

.step-connector.done { background: var(--success); }

/* ===================== 主面板 ===================== */
.panel {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
    margin-bottom: 20px;
}

/* ===================== 分区标题 ===================== */
.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.section-header h2 { font-size: 1.1rem; font-weight: 600; }

.section-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* 状态指示灯 */
.status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.connected { background: var(--success); box-shadow: 0 0 6px rgba(22,163,74,0.5); }
.status-dot.disconnected { background: var(--danger); }
.status-dot.connecting { background: var(--warning); animation: pulse 1s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ===================== 设备信息 ===================== */
.device-info {
    background: #f1f5f9;
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 16px;
}

.info-row {
    display: flex;
    padding: 4px 0;
    font-size: 0.9rem;
}

.info-label { color: var(--text-secondary); min-width: 110px; }
.info-value { font-weight: 500; font-family: monospace; }

/* ===================== 按钮 ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); }

.btn-flash {
    background: linear-gradient(135deg, #16a34a, #15803d);
    color: white;
    padding: 14px 36px;
    font-size: 1.1rem;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(22,163,74,0.3);
}
.btn-flash:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(22,163,74,0.4);
}
.btn-flash:disabled { background: #94a3b8; box-shadow: none; }

.btn-secondary {
    background: var(--border);
    color: var(--text);
}
.btn-secondary:hover { background: var(--border-hover); }

.btn-small {
    padding: 4px 12px;
    font-size: 0.8rem;
    background: transparent;
    color: var(--text-secondary);
}
.btn-small:hover { background: var(--border); }

.btn-connect { margin-top: 8px; }
.btn-icon { font-size: 1.1rem; }

.flash-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

/* ===================== 固件选择 ===================== */
.firmware-option {
    display: block;
    cursor: pointer;
}

.firmware-option input { display: none; }

.firmware-card {
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    transition: all 0.2s;
}

.firmware-option.selected .firmware-card {
    border-color: var(--primary);
    background: var(--primary-light);
}

.fw-name { font-weight: 600; font-size: 1rem; }
.fw-version { color: var(--text-secondary); font-size: 0.85rem; margin: 2px 0; }
.fw-desc { color: var(--text-secondary); font-size: 0.85rem; }

/* ===================== 进度条 ===================== */
.progress-section {
    margin-bottom: 16px;
}

.progress-bar-bg {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 8px;
}

.progress-percent {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--primary);
    margin-top: 4px;
}

/* ===================== 日志区域 ===================== */
.log-section {
    margin-top: 8px;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}

.log-area {
    height: 200px;
    overflow-y: auto;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 0.8rem;
    line-height: 1.5;
}

.log-entry { padding: 1px 0; }
.log-entry.info { color: #60a5fa; }
.log-entry.success { color: #4ade80; }
.log-entry.error { color: #f87171; }
.log-entry.warn { color: #fbbf24; }
.log-entry.progress { color: #c084fc; }

/* ===================== 完成状态 ===================== */
.complete-section {
    text-align: center;
    padding: 20px 0;
}

.complete-icon { font-size: 3rem; margin-bottom: 12px; }
.complete-section h2 { font-size: 1.4rem; margin-bottom: 8px; }
.complete-section p { color: var(--text-secondary); margin-bottom: 20px; }

.complete-actions { display: flex; justify-content: center; gap: 12px; }

/* ===================== 使用说明 ===================== */
.guide {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 28px;
    margin-bottom: 20px;
}

.guide h3 { font-size: 1rem; margin-bottom: 12px; }

.guide ol {
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.guide li {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.guide li strong { color: var(--text); }

kbd {
    background: var(--border);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: inherit;
    border: 1px solid var(--border-hover);
}

/* ===================== 页脚 ===================== */
.footer {
    margin-top: auto;
    background: #1e293b;
    color: #94a3b8;
    padding: 20px 0;
    text-align: center;
    font-size: 0.8rem;
}

.footer-hint { font-size: 0.75rem; margin-top: 4px; }

/* ===================== 响应式 ===================== */
@media (max-width: 600px) {
    .header { padding: 16px 0; }
    .logo { font-size: 1.1rem; }
    .panel { padding: 20px; }
    .steps { gap: 0; }
    .step-connector { width: 30px; }
}
