/* ===== 基础样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;
    --primary-glow: rgba(99, 102, 241, 0.15);
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 40px -10px rgba(0, 0, 0, 0.15);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--gray-800);
    -webkit-font-smoothing: antialiased;
}

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

/* ===== 头部 ===== */
.header {
    text-align: center;
    margin-bottom: 36px;
    color: white;
}

.header h1 {
    font-size: 2.4rem;
    font-weight: 800;
    margin-bottom: 10px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 400;
    letter-spacing: 0.3px;
}

/* ===== 步骤指示器 ===== */
.steps {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 32px;
    gap: 6px;
}

.step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.88rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    user-select: none;
    backdrop-filter: blur(4px);
}

.step:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: translateY(-2px);
}

.step.active {
    background: white;
    color: var(--primary);
    font-weight: 700;
    box-shadow: var(--shadow-lg), 0 0 20px var(--primary-glow);
    cursor: default;
    transform: translateY(-2px);
}

.step.done {
    background: rgba(255, 255, 255, 0.45);
    color: white;
}

.step.done:hover {
    background: rgba(255, 255, 255, 0.6);
}

.step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 800;
    transition: var(--transition);
}

.step.active .step-num {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.step-line {
    width: 28px;
    height: 2px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 1px;
}

/* ===== 区块 ===== */
.section {
    background: white;
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow-xl);
    margin-bottom: 24px;
    animation: slideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

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

.section h2 {
    font-size: 1.35rem;
    margin-bottom: 24px;
    color: var(--gray-800);
    font-weight: 700;
    letter-spacing: -0.3px;
}

.hidden {
    display: none !important;
}

/* ===== 上传区域 ===== */
.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 48px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 20px;
    background: var(--gray-50);
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary-glow), transparent);
    opacity: 0;
    transition: var(--transition);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.upload-area:hover::before,
.upload-area.dragover::before {
    opacity: 1;
}

.upload-icon {
    font-size: 3.5rem;
    margin-bottom: 12px;
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.upload-area p {
    position: relative;
    z-index: 1;
}

.upload-hint {
    color: var(--gray-400);
    font-size: 0.85rem;
    margin-top: 8px;
}

/* ===== 文件信息 ===== */
.file-info {
    background: linear-gradient(135deg, var(--gray-50), #f0fdf4);
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    margin-bottom: 20px;
}

.file-detail {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-name {
    font-weight: 700;
    color: var(--gray-800);
    font-size: 0.95rem;
}

.file-size {
    color: var(--gray-400);
    font-size: 0.82rem;
    background: white;
    padding: 2px 10px;
    border-radius: 12px;
}

.btn-remove {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px 8px;
    border-radius: var(--radius-xs);
    transition: var(--transition);
}

.btn-remove:hover {
    color: var(--danger);
    background: #fef2f2;
}

.chapter-list {
    margin-top: 12px;
    max-height: 180px;
    overflow-y: auto;
    border-top: 1px solid var(--gray-200);
    padding-top: 8px;
}

.chapter-item {
    display: flex;
    justify-content: space-between;
    padding: 7px 4px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.88rem;
    transition: var(--transition);
    border-radius: var(--radius-xs);
}

.chapter-item:hover {
    background: var(--gray-50);
}

.chapter-item:last-child {
    border-bottom: none;
}

.chapter-title {
    color: var(--gray-700);
    font-weight: 500;
}

.chapter-chars {
    color: var(--gray-400);
    font-size: 0.78rem;
    background: var(--gray-100);
    padding: 1px 8px;
    border-radius: 8px;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gray-700);
    font-size: 0.92rem;
}

.required {
    color: var(--danger);
}

.input {
    width: 100%;
    padding: 11px 16px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
    background: white;
    color: var(--gray-800);
}

.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.input::placeholder {
    color: var(--gray-300);
}

.form-hint {
    font-size: 0.8rem;
    color: var(--gray-400);
    margin-top: 6px;
}

/* ===== 按钮 ===== */
.btn {
    padding: 11px 28px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.2px;
    position: relative;
    overflow: hidden;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-200);
    transform: translateY(-1px);
}

.btn-group {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

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

.progress-bar {
    height: 10px;
    background: var(--gray-100);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #8b5cf6, #a78bfa);
    border-radius: 5px;
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    font-size: 0.88rem;
    color: var(--gray-500);
    font-weight: 500;
}

/* ===== 转换日志 ===== */
.conversion-log {
    max-height: 320px;
    overflow-y: auto;
    background: linear-gradient(135deg, #1e1e2e, #181825);
    border-radius: var(--radius-sm);
    padding: 18px 20px;
    font-family: "Fira Code", "JetBrains Mono", "Consolas", "Monaco", monospace;
    font-size: 0.82rem;
    line-height: 1.9;
    border: 1px solid #313244;
}

.conversion-log::-webkit-scrollbar {
    width: 6px;
}

.conversion-log::-webkit-scrollbar-track {
    background: transparent;
}

.conversion-log::-webkit-scrollbar-thumb {
    background: #45475a;
    border-radius: 3px;
}

.log-entry {
    padding: 3px 0;
    color: #a6adc8;
}

.log-entry.success {
    color: #a6e3a1;
}

.log-entry.error {
    color: #f38ba8;
}

/* ===== 结果展示 ===== */
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.result-stats {
    display: flex;
    gap: 12px;
}

.result-stats span {
    background: linear-gradient(135deg, var(--primary-light), #f0f0ff);
    color: var(--primary);
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.result-actions {
    display: flex;
    gap: 8px;
}

.yaml-viewer {
    background: linear-gradient(135deg, #1e1e2e, #181825);
    border-radius: var(--radius);
    padding: 24px;
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #313244;
}

.yaml-viewer::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.yaml-viewer::-webkit-scrollbar-track {
    background: transparent;
}

.yaml-viewer::-webkit-scrollbar-thumb {
    background: #45475a;
    border-radius: 3px;
}

.yaml-viewer pre {
    color: #cdd6f4;
    font-family: "Fira Code", "JetBrains Mono", "Consolas", "Monaco", monospace;
    font-size: 0.82rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ===== 提供商选择 ===== */
.provider-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 8px;
}

.provider-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 12px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: white;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.provider-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.provider-btn.active {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-glow), var(--shadow-md);
    transform: translateY(-2px);
}

.provider-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1));
}

.provider-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--gray-700);
    text-align: center;
}

.provider-tag {
    font-size: 0.68rem;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.provider-tag.free {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    color: #166534;
}

.provider-tag.cheap {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
}

.provider-tag.paid {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #991b1b;
}

.provider-hint {
    background: linear-gradient(135deg, #fef3c7, #fffbeb);
    border: 1px solid #fde68a;
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: #92400e;
    line-height: 1.6;
}

.provider-hint code {
    background: rgba(0,0,0,0.08);
    padding: 2px 8px;
    border-radius: var(--radius-xs);
    font-size: 0.8rem;
    font-family: "Fira Code", "Consolas", monospace;
}

.provider-hint a {
    color: #92400e;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

#api-config-section {
    transition: var(--transition);
}

#api-config-section.disabled {
    opacity: 0.35;
    pointer-events: none;
    filter: grayscale(0.5);
}

/* ===== 响应式 ===== */
@media (max-width: 640px) {
    .container {
        padding: 20px 12px;
    }

    .header h1 {
        font-size: 1.7rem;
    }

    .steps {
        flex-wrap: wrap;
        gap: 4px;
    }

    .step-line {
        display: none;
    }

    .step {
        padding: 8px 12px;
        font-size: 0.82rem;
    }

    .section {
        padding: 20px;
    }

    .result-header {
        flex-direction: column;
    }

    .provider-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .btn-group {
        flex-direction: column;
    }

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

/* ===== 滚动条全局美化 ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-50);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* ===== 选中文本颜色 ===== */
::selection {
    background: var(--primary);
    color: white;
}
