/* ============================================
   智能软文生成系统 - 商务风格样式
   上下布局版本
   ============================================ */

/* CSS 变量定义 - 商务蓝色系 */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --secondary-color: #64748b;
    --accent-color: #0ea5e9;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;

    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;

    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --transition: all 0.3s ease;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

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

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

/* ============================================
   头部样式
   ============================================ */
.header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    color: white;
    padding: 20px 0;
    box-shadow: var(--shadow-lg);
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-icon {
    font-size: 2.2rem;
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.subtitle {
    font-size: 0.85rem;
    opacity: 0.95;
    margin-top: 4px;
}

.brand-tag {
    display: inline-block;
    margin-top: 6px;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-api {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-md);
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.btn-api:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--error-color);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.status-dot.active {
    background: var(--success-color);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

/* ============================================
   主内容区 - 上下布局
   ============================================ */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 25px;
    padding: 25px 0;
}

/* ============================================
   配置区域（上半部分）
   ============================================ */
.config-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.config-header {
    padding: 20px 25px;
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    border-bottom: 1px solid var(--border-color);
}

.config-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.config-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.config-content {
    padding: 25px;
}

/* 配置块 */
.config-block {
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
}

.config-block:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.block-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 18px;
}

.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 70px;
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.block-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.block-content {
    padding-left: 85px;
}

/* 软文形式网格 */
.formats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.format-card {
    position: relative;
    cursor: pointer;
}

.format-card input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.format-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
    background: var(--bg-secondary);
}

.format-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
}

.format-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.format-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.format-desc {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.format-card input[type="checkbox"]:checked + .format-info {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08) 0%, rgba(14, 165, 233, 0.08) 100%);
}

.format-card:hover .format-info {
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.format-card input[type="checkbox"]:checked + .format-info {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

/* 动态表单区域 */
.format-fields {
    margin-top: 20px;
    padding: 18px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
}

.field-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 15px;
}

/* 表单元素 */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group {
    margin-bottom: 15px;
}

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

.form-group.half {
    margin-bottom: 0;
}

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

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 11px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: var(--transition);
    background: var(--bg-secondary);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 70px;
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 35px;
}

/* 配置行（平台和参数并排） */
.config-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.flex-1 {
    flex: 1;
}

/* 平台选择（紧凑版） */
.platform-compact {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.platform-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.platform-checkbox input {
    accent-color: var(--primary-color);
    width: 16px;
    height: 16px;
}

.platform-checkbox:hover {
    border-color: var(--primary-light);
    background: rgba(37, 99, 235, 0.03);
}

.platform-checkbox:has(input:checked) {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary-color);
    font-weight: 500;
}

/* 参数网格 */
.params-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

/* 计数器控制 */
.counter-control {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.counter-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    color: var(--primary-color);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

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

.counter-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 20px;
    text-align: center;
}

/* 生成按钮区域 */
.generate-section {
    margin-top: 25px;
    padding-top: 25px;
    border-top: 2px solid var(--border-color);
    text-align: center;
}

.btn-generate {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 50px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
}

.btn-generate:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

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

.btn-icon {
    font-size: 1.3rem;
}

.generate-hint {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

/* ============================================
   结果区域（下半部分）
   ============================================ */
.result-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.result-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 15px;
}

.result-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.result-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.result-count {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    background: var(--primary-color);
    color: white;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

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

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.btn-action:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

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

/* 结果内容区 */
.result-content {
    min-height: 300px;
    max-height: 600px;
    overflow-y: auto;
}

/* 空状态 */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 30px;
    text-align: center;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 3.5rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.empty-state p {
    margin-bottom: 20px;
}

.empty-tips {
    max-width: 400px;
    text-align: left;
    background: var(--bg-tertiary);
    padding: 18px;
    border-radius: var(--radius-md);
}

.empty-tips p {
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.empty-tips ul {
    list-style: none;
    padding-left: 0;
}

.empty-tips li {
    padding: 4px 0;
    padding-left: 20px;
    position: relative;
    font-size: 0.85rem;
}

.empty-tips li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: 700;
}

/* 加载状态 */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 30px;
    text-align: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 18px;
}

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

.loading-state h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.loading-state p {
    color: var(--text-secondary);
    margin-bottom: 18px;
}

.progress-bar {
    width: 280px;
    height: 6px;
    background: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 10px;
    animation: progress 2s ease-in-out infinite;
    width: 0;
}

@keyframes progress {
    0% {
        width: 0%;
    }
    50% {
        width: 70%;
    }
    100% {
        width: 100%;
    }
}

/* 结果卡片 */
.result-cards {
    display: grid;
    gap: 20px;
    padding: 25px;
}

.result-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition);
    background: var(--bg-secondary);
}

.result-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.result-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 10px;
}

.result-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.result-card-badges {
    display: flex;
    gap: 8px;
    align-items: center;
}

.result-card-badge {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 500;
}

.badge-format {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
}

.badge-platform {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.badge-version {
    background: var(--success-color);
    color: white;
}

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

.btn-card-action {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-card-action:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
}

.result-card-body {
    padding: 18px;
    max-height: 350px;
    overflow-y: auto;
}

.result-card-content {
    font-size: 0.92rem;
    line-height: 1.8;
    color: var(--text-secondary);
    white-space: pre-wrap;
}

.result-card-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* ============================================
   模态框
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(5px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

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

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

.modal-header h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.6rem;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
}

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

.modal-body {
    padding: 22px;
}

.api-hint {
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.api-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-family: monospace;
    transition: var(--transition);
}

.api-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.api-note {
    margin-top: 12px;
}

.api-note small {
    color: var(--text-tertiary);
    font-size: 0.82rem;
}

.api-note a {
    color: var(--primary-color);
    text-decoration: none;
}

.api-note a:hover {
    text-decoration: underline;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 18px 22px;
    border-top: 1px solid var(--border-color);
}

.btn {
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

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

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

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

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

/* ============================================
   Toast 提示
   ============================================ */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: 12px 22px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    opacity: 0;
    transition: var(--transition);
    font-size: 0.9rem;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--error-color);
}

/* ============================================
   页脚
   ============================================ */
.footer {
    text-align: center;
    padding: 20px 0;
    color: var(--text-tertiary);
    font-size: 0.8rem;
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
}

.footer p {
    margin: 4px 0;
}

.footer-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 20px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: white;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.footer-note {
    font-size: 0.75rem;
}

/* ============================================
   响应式设计
   ============================================ */

/* 平板 */
@media (min-width: 768px) {
    .formats-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .platform-compact {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 小屏优化 */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .btn-api {
        align-self: flex-end;
    }

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

    .form-row {
        grid-template-columns: 1fr;
    }

    .config-row {
        grid-template-columns: 1fr;
    }

    .block-content {
        padding-left: 0;
        margin-top: 10px;
    }

    .block-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .params-grid {
        grid-template-columns: 1fr;
    }

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

    .result-header-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-actions {
        width: 100%;
        justify-content: stretch;
    }

    .btn-action {
        flex: 1;
        justify-content: center;
    }
}

/* 滚动条样式 */
.result-content::-webkit-scrollbar,
.result-card-body::-webkit-scrollbar {
    width: 7px;
}

.result-content::-webkit-scrollbar-track,
.result-card-body::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 10px;
}

.result-content::-webkit-scrollbar-thumb,
.result-card-body::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 10px;
}

.result-content::-webkit-scrollbar-thumb:hover,
.result-card-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* 打印样式 */
@media print {
    .header,
    .config-section,
    .result-header-bar,
    .footer,
    .btn-action {
        display: none;
    }

    .result-section {
        box-shadow: none;
    }

    .result-card {
        page-break-inside: avoid;
    }
}
