/**
 * 商务洽谈剧本生成器 - 样式表
 */

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

:root {
    --primary-color: #1890ff;
    --primary-hover: #40a9ff;
    --success-color: #52c41a;
    --warning-color: #faad14;
    --error-color: #f5222d;
    --text-primary: #262626;
    --text-secondary: #8c8c8c;
    --border-color: #d9d9d9;
    --bg-color: #f0f2f5;
    --card-bg: #ffffff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background-color: var(--bg-color);
    line-height: 1.5;
}

/* === 登录页面 === */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-card h1 {
    font-size: 24px;
    margin-bottom: 10px;
    text-align: center;
    color: var(--text-primary);
}

.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.login-form {
    margin-bottom: 20px;
}

.login-footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
}

/* === 应用布局 === */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    max-width: 1600px;
    margin: 0 auto;
}

.app-header h1 {
    font-size: 20px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-id {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 12px;
    background: var(--bg-color);
    border-radius: 4px;
}

.app-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* === 侧边栏 === */
.sidebar {
    width: 350px;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

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

.section-title {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}

.radio-group {
    display: flex;
    gap: 16px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.scenario-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 4px;
    font-weight: 500;
}

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

input[type="text"],
input[type="password"],
textarea {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

textarea {
    font-family: monospace;
    resize: vertical;
}

/* === 按钮 === */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

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

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

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

.btn-danger:hover:not(:disabled) {
    background: #cf1322;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 13px;
}

/* === 主内容区 === */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-color);
}

.tabs {
    display: flex;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
}

.tab-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.3s;
}

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

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-panel {
    display: none;
    flex: 1;
    overflow: hidden;
}

.tab-panel.active {
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}

.panel-header h3 {
    font-size: 16px;
    font-weight: 600;
}

/* === 任务列表 === */
.tasks-list,
.batches-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

/* 批次任务项 */
.batch-task-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
}

.batch-task-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.batch-task-header h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.batch-task-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.batch-progress {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-color);
    border-radius: 4px;
}

/* 场景列表 */
.batch-scenarios-list {
    margin-bottom: 16px;
}

.scenario-task-item {
    padding: 12px;
    background: var(--bg-color);
    border-radius: 4px;
    margin-bottom: 8px;
    border-left: 3px solid var(--border-color);
}

.scenario-task-item.status-running {
    border-left-color: var(--primary-color);
}

.scenario-task-item.status-success {
    border-left-color: var(--success-color);
}

.scenario-task-item.status-error {
    border-left-color: var(--error-color);
}

.scenario-task-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.scenario-name {
    font-weight: 500;
    font-size: 14px;
}

.scenario-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 3px;
    background: var(--bg-color);
}

.scenario-progress {
    font-size: 12px;
    color: var(--text-secondary);
}

.progress-text {
    display: block;
    margin-bottom: 4px;
}

.progress-bar-sm {
    height: 4px;
    background: #e8e8e8;
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-sm .progress-fill {
    height: 100%;
}

.scenario-error-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
}

.scenario-error {
    flex: 1;
    font-size: 12px;
    color: var(--error-color);
    padding: 6px 8px;
    background: #fff1f0;
    border-radius: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.retry-btn {
    flex-shrink: 0;
}

.btn-warning {
    background-color: var(--warning-color);
    color: #fff;
    border: none;
}

.btn-warning:hover {
    background-color: #d48806;
}

/* 批次操作 */
.batch-task-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.action-hint {
    font-size: 12px;
    color: var(--text-secondary);
}

.task-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 12px;
    transition: box-shadow 0.3s;
}

.task-item:hover {
    box-shadow: var(--shadow);
}

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

.task-header h4 {
    font-size: 15px;
    font-weight: 600;
}

.task-status {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.status-pending {
    background: #f0f0f0;
    color: var(--text-secondary);
}

.status-waiting {
    background: #fffbe6;
    color: #d48806;
}

.status-running {
    background: #e6f7ff;
    color: var(--primary-color);
}

.status-success {
    background: #f6ffed;
    color: var(--success-color);
}

.status-error {
    background: #fff1f0;
    color: var(--error-color);
}

.status-aborted {
    background: #fff7e6;
    color: #d46b08;
}

.scenario-task-item.status-aborted {
    border-left-color: #d46b08;
}

.batch-task-item.status-aborted {
    border-left-color: #d46b08;
}

/* === HTML生成状态提示 === */
/* HTML状态徽章 */
.html-status-badge {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.html-status-badge.pending {
    background: #f0f0f0;
    color: #666;
}

.html-status-badge.generating {
    background: #fff7e6;
    color: #d46b08;
    animation: pulse 1.5s infinite;
}

.html-status-badge.completed {
    background: #f6ffed;
    color: #52c41a;
}

.html-status-badge.failed {
    background: #fff1f0;
    color: #ff4d4f;
}

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

.html-generation-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin: 12px 0;
    background: linear-gradient(135deg, #e6f7ff 0%, #f0f5ff 100%);
    border: 1px solid #91d5ff;
    border-radius: 8px;
    animation: fadeIn 0.3s ease;
}

.html-generation-status.generating {
    background: linear-gradient(135deg, #fff7e6 0%, #fffbe6 100%);
    border-color: #ffd591;
}

.html-generation-status.failed {
    background: linear-gradient(135deg, #fff1f0 0%, #ffccc7 100%);
    border-color: #ffa39e;
}

.html-status-icon {
    font-size: 24px;
    line-height: 1;
}

.html-status-text {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.html-progress-indicator {
    display: flex;
    align-items: center;
}

.html-progress-indicator .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #ffd591;
    border-top-color: #fa8c16;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.task-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

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

.task-error {
    margin-top: 8px;
    padding: 8px;
    background: #fff1f0;
    border-radius: 4px;
    color: var(--error-color);
    font-size: 12px;
}

/* === 任务进度条 === */
.task-progress {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-color);
    border-radius: 4px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-primary);
}

.progress-info span:last-child {
    font-weight: 600;
    color: var(--primary-color);
}

.progress-bar {
    height: 8px;
    background: #e8e8e8;
    border-radius: 4px;
    overflow: hidden;
}

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

.files-completed {
    margin-top: 12px;
    cursor: pointer;
}

.files-completed summary {
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
}

.files-completed summary:hover {
    color: var(--primary-color);
}

.files-completed .file-list {
    margin-top: 8px;
    padding-left: 16px;
}

.files-completed .file-list li {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 0;
    border-bottom: 1px solid #f0f0f0;
}

.files-completed .file-list li:last-child {
    border-bottom: none;
}

/* === 批次列表 === */
.batch-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
}

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

.batch-header > div:first-child {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.batch-header h4 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

.batch-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.batch-time {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
}

.batch-scenarios {
    margin-bottom: 12px;
}

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

.scenario-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.scenario-info strong {
    font-size: 14px;
}

.scenario-info span {
    font-size: 12px;
    color: var(--text-secondary);
}

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

.batch-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

/* === 预览区域 === */
.preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.file-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--card-bg);
    border-radius: 6px;
}

.file-list-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    transition: box-shadow 0.3s;
}

.file-item:hover {
    box-shadow: var(--shadow);
}

.file-name {
    font-weight: 500;
}

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

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--card-bg);
    border-radius: 6px;
}

.preview-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.preview-header div {
    display: flex;
    gap: 8px;
}

.markdown-content {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 6px;
    line-height: 1.8;
}

.markdown-content h1 {
    font-size: 28px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

.markdown-content h2 {
    font-size: 24px;
    margin-top: 24px;
    margin-bottom: 12px;
}

.markdown-content h3 {
    font-size: 20px;
    margin-top: 20px;
    margin-bottom: 10px;
}

.markdown-content p {
    margin-bottom: 12px;
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.markdown-content table th,
.markdown-content table td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}

.markdown-content table th {
    background: var(--bg-color);
    font-weight: 600;
}

.markdown-content ul,
.markdown-content ol {
    margin-bottom: 12px;
    padding-left: 24px;
}

.markdown-content li {
    margin-bottom: 4px;
}

.markdown-content code {
    background: var(--bg-color);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.markdown-content pre {
    background: var(--bg-color);
    padding: 12px;
    border-radius: 4px;
    overflow-x: auto;
    margin-bottom: 12px;
}

.markdown-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--text-secondary);
}

/* === Toast通知 === */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--card-bg);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    border-left: 4px solid var(--success-color);
}

.toast-error {
    border-left: 4px solid var(--error-color);
}

.toast-warning {
    border-left: 4px solid var(--warning-color);
}

.toast-info {
    border-left: 4px solid var(--primary-color);
}

/* === 错误消息 === */
.error-message {
    margin-top: 12px;
    padding: 8px 12px;
    background: #fff1f0;
    border: 1px solid #ffccc7;
    border-radius: 4px;
    color: var(--error-color);
    font-size: 13px;
}

/* === 响应式设计 === */
@media (max-width: 768px) {
    .app-main {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .header-content {
        padding: 12px 16px;
    }

    .app-header h1 {
        font-size: 16px;
    }

    .tabs {
        padding: 0 16px;
    }

    .panel-header,
    .preview-content {
        padding: 12px 16px;
    }

    .tasks-list,
    .batches-list {
        padding: 12px 16px;
    }
}

/* 批次级别文件样式 */
.batch-files-section {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.batch-files-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.batch-files-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.batch-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.batch-file-item .file-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.batch-file-item .file-actions {
    display: flex;
    gap: 8px;
}

/* HTML预览样式 */
.html-preview {
    margin-top: 16px;
}

.text-preview {
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
}

/* === 场景不完整状态样式 === */
.scenario-incomplete {
    border-left: 3px solid var(--warning-color);
    background: linear-gradient(90deg, #fffbe6 0%, var(--bg-color) 20%);
}

.scenario-incomplete .scenario-info strong {
    color: var(--text-primary);
}

.incomplete-icon {
    margin-left: 6px;
    font-size: 14px;
    cursor: help;
}

.file-count-warning {
    color: var(--warning-color) !important;
    font-weight: 500;
}

/* === 场景生成中状态样式 === */
.scenario-generating {
    border-left: 3px solid var(--primary-color);
    background: linear-gradient(90deg, #e6f7ff 0%, var(--bg-color) 20%);
}

.generating-icon {
    margin-left: 6px;
    font-size: 14px;
    animation: pulse 1.5s infinite;
}

.file-count-generating {
    color: var(--primary-color) !important;
    font-weight: 500;
}

/* === HTML缺失提示 === */
.html-missing-notice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #fffbe6 0%, #fff7e6 100%);
    border-radius: 6px;
    border: 1px dashed #ffd591;
}

.html-missing-notice .notice-icon {
    font-size: 20px;
}

.html-missing-notice .notice-text {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
}

/* === 场景操作按钮组样式优化 === */
.scenario-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.scenario-actions .btn-warning {
    background: var(--warning-color);
    color: #fff;
    font-weight: 500;
}

.scenario-actions .btn-warning:hover {
    background: #d48806;
}

/* === 批次文件操作按钮组 === */
.batch-files-actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(24, 144, 255, 0.05);
}

.btn-outline:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    border-color: var(--border-color);
    color: var(--text-secondary);
}

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

/* === HTML生成中状态 === */
.html-generating-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: linear-gradient(135deg, #e6f7ff 0%, #f0f5ff 100%);
    border: 1px solid #91d5ff;
    border-radius: 6px;
    margin-bottom: 12px;
}

.generating-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #91d5ff;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.generating-text {
    flex: 1;
    font-size: 13px;
    color: var(--primary-color);
    font-weight: 500;
}

.generating-progress {
    font-size: 12px;
    color: var(--primary-color);
    font-weight: 600;
    padding: 2px 8px;
    background: rgba(24, 144, 255, 0.1);
    border-radius: 10px;
}
