/* ========================================
   CSS 变量
   ======================================== */
:root {
    --primary: #4a90d9;
    --primary-hover: #357abd;
    --primary-light: rgba(74, 144, 217, 0.12);
    --primary-glow: rgba(74, 144, 217, 0.25);
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #1e2a45;
    --bg-input: #0f1b33;
    --text-primary: #e0e0e0;
    --text-secondary: #8892a8;
    --text-hint: #5c6a85;
    --border-color: #2a3a5c;
    --border-light: rgba(42, 58, 92, 0.6);
    --success: #4caf50;
    --success-bg: rgba(76, 175, 80, 0.1);
    --danger: #f44336;
    --danger-bg: rgba(244, 67, 54, 0.1);
    --warning: #ff9800;
    --sidebar-width: 260px;
    --toolbar-height: 50px;
    --input-height: 120px;
    --radius: 8px;
    --radius-lg: 12px;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.15);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.2);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.3);
    --transition: 0.2s ease;
}

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

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   登录页
   ======================================== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(74, 144, 217, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(74, 144, 217, 0.05) 0%, transparent 50%),
        linear-gradient(160deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.login-logo {
    text-align: center;
    margin-bottom: 40px;
}

.login-logo .logo-icon {
    width: 56px;
    height: 56px;
    color: var(--primary);
    margin-bottom: 16px;
    filter: drop-shadow(0 2px 8px rgba(74, 144, 217, 0.3));
}

.login-logo h1 {
    font-size: 26px;
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ========================================
   安装向导页
   ======================================== */
.install-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 48px 24px 32px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.install-header {
    text-align: center;
    margin-bottom: 40px;
}

.install-logo {
    margin-bottom: 16px;
}

.install-logo svg {
    width: 48px;
    height: 48px;
    color: var(--primary);
    filter: drop-shadow(0 2px 8px rgba(74, 144, 217, 0.3));
}

.install-header h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.install-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 400px;
    margin: 0 auto;
}

.install-footer {
    text-align: center;
    padding: 24px 0 8px;
    margin-top: auto;
    font-size: 12px;
    color: var(--text-hint);
}

/* 步骤指示器 */
.step-indicator {
    display: flex;
    justify-content: space-between;
    margin-bottom: 36px;
    padding: 0;
    list-style: none;
    gap: 4px;
}

.step-indicator .step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 4px 0;
    position: relative;
}

.step-indicator .step::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border-color);
    border-radius: 2px;
    transition: background var(--transition);
}

.step-indicator .step.active::after {
    background: var(--primary);
}

.step-indicator .step.completed::after {
    background: var(--success);
}

.step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition);
}

.step.active .step-num {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(74, 144, 217, 0.35);
}

.step.completed .step-num {
    background: var(--success);
    color: #fff;
}

.step-label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: color var(--transition);
}

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

.step.completed .step-label {
    color: var(--success);
}

/* 步骤内容卡片 */
.step-content {
    display: none;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    animation: stepFadeIn 0.3s ease;
}

.step-content.active {
    display: block;
}

@keyframes stepFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.step-header {
    margin-bottom: 24px;
}

.step-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
}

.step-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

/* 环境检查列表 */
.check-list {
    margin-bottom: 8px;
}

.check-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 6px;
    background: var(--bg-secondary);
    transition: background var(--transition);
}

.check-item:last-child {
    margin-bottom: 0;
}

.check-name {
    font-size: 14px;
    color: var(--text-primary);
}

.check-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
}

.check-status svg {
    vertical-align: -2px;
}

.check-item.pass .check-status {
    color: var(--success);
}

.check-item.fail .check-status {
    color: var(--danger);
}

.check-item.fail {
    background: var(--danger-bg);
    border: 1px solid rgba(244, 67, 54, 0.2);
}

.check-item.pass {
    border: 1px solid transparent;
}

/* 供应商配置卡片 */
.provider-item {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    border: 1px solid var(--border-light);
}

.provider-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.provider-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.provider-item .form-group {
    margin-bottom: 12px;
}

.provider-item .form-group:last-child {
    margin-bottom: 0;
}

/* ========================================
   通用表单
   ======================================== */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: all var(--transition);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-hint);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* 表单行（并排布局） */
.form-row {
    display: flex;
    gap: 16px;
}

@media (max-width: 600px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

/* 输入框+按钮行 */
.input-action-row {
    display: flex;
    gap: 8px;
}

.input-action-row input {
    flex: 1;
}

/* 表单提示文字 */
.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-hint);
}

/* ========================================
   按钮
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 144, 217, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary-light);
}

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

.btn-danger:hover {
    opacity: 0.9;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

.btn-lg {
    padding: 12px 32px;
    font-size: 15px;
    font-weight: 600;
}

.btn-block {
    display: flex;
    width: 100%;
    text-align: center;
}

.btn-group {
    display: flex;
    gap: 10px;
    margin-top: 28px;
    justify-content: flex-end;
}

/* ========================================
   消息提示
   ======================================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-error {
    background: var(--danger-bg);
    border: 1px solid rgba(244, 67, 54, 0.3);
    color: var(--danger);
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid rgba(76, 175, 80, 0.3);
    color: var(--success);
}

/* ========================================
   配置页
   ======================================== */
.config-container {
    max-width: 900px;
    margin: 40px auto;
    padding: 0 20px;
}

.config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.config-header h1 {
    display: flex;
    align-items: center;
    font-size: 22px;
    font-weight: 600;
}

.config-header h1 svg {
    color: var(--primary);
}

.config-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.config-section h2 {
    margin-bottom: 20px;
    font-size: 17px;
    font-weight: 600;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

/* ========================================
   响应式
   ======================================== */
@media (max-width: 768px) {
    .login-card {
        padding: 32px 24px;
    }

    .install-container {
        padding: 24px 16px 16px;
    }

    .step-content {
        padding: 24px 20px;
    }

    .step-label {
        display: none;
    }

    .step-indicator {
        gap: 0;
    }

    .install-header h1 {
        font-size: 22px;
    }

    .install-subtitle {
        font-size: 13px;
    }

    .config-container {
        margin: 20px auto;
        padding: 0 12px;
    }

    .config-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 24px 20px;
        border-radius: var(--radius);
    }

    .login-logo .logo-icon {
        width: 44px;
        height: 44px;
    }

    .login-logo h1 {
        font-size: 22px;
    }
}

/* ========================================
   工具类
   ======================================== */
.hidden { display: none !important; }
.ml-auto { margin-left: auto; }
.mt-sm { margin-top: 12px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.full-width { width: 100%; }
.text-muted { color: var(--text-secondary); }
.text-xs { font-size: 12px; }
.text-center { text-align: center; }
.col-flex-2 { flex: 2; }
.col-flex-1 { flex: 1; }

/* 内联 SVG 图标对齐 */
.icon-inline {
    vertical-align: -2px;
    margin-right: 4px;
}

.icon-inline-md {
    vertical-align: -4px;
    margin-right: 8px;
}

/* ========================================
   聊天页工具栏组件
   ======================================== */
.toolbar-think-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.upload-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}

.settings-link {
    margin-left: auto;
}

/* ========================================
   配置页组件
   ======================================== */
.config-add-btn {
    margin-top: 12px;
}

.config-section h3 {
    margin-top: 20px;
    margin-bottom: 16px;
    font-size: 15px;
    font-weight: 600;
}

.config-empty {
    color: var(--text-secondary);
}

.config-provider-card {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 12px;
}

.config-provider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.config-provider-header strong {
    font-size: 15px;
}

.config-provider-header .toggle-switch {
    margin-right: 8px;
}

.personality-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.personality-icon {
    margin-right: 4px;
}

.personality-badge {
    font-size: 12px;
    margin-left: 8px;
}

.personality-badge.preset {
    color: var(--warning);
}

.personality-badge.custom {
    color: var(--success);
}

/* 固定定位消息提示（配置页用） */
.toast-message {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    min-width: 200px;
}
