/* Copywriting Studio - 全局样式 */

:root {
    --primary: #667eea;
    --primary-dark: #5a6fd6;
    --accent: #764ba2;
    --bg: #f0f2f5;
    --card-bg: #fff;
    --text: #333;
    --text-secondary: #666;
    --text-muted: #999;
    --border: #e8ecf1;
    --success: #4caf50;
    --warning: #ff9800;
    --error: #f44336;
    --info: #2196f3;
    --sidebar-width: 220px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

/* ====== 布局 ====== */
.app-layout {
    display: flex;
    height: 100vh;
}

/* ====== 侧边栏 ====== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-header .subtitle {
    font-size: 11px;
    color: rgba(255,255,255,0.4);
    margin-top: 2px;
}

.nav-section {
    padding: 12px 0;
}

.nav-section-title {
    font-size: 10px;
    color: rgba(255,255,255,0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 4px 16px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 14px;
    color: rgba(255,255,255,0.7);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: rgba(102,126,234,0.2); color: #fff; }
.nav-item .icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }
.nav-item .label { flex: 1; }
.nav-item .badge {
    font-size: 10px; padding: 2px 6px; border-radius: 8px;
    background: rgba(102,126,234,0.3); color: #a8b5ff;
}

.sidebar-footer {
    margin-top: auto;
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.btn-settings {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-radius: 8px;
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.6);
    cursor: pointer; font-size: 13px;
    border: none; width: 100%;
    transition: background 0.15s;
}
.btn-settings:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ====== 主区域 ====== */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* 顶部栏 */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.topbar-title {
    font-size: 16px;
    font-weight: 600;
}

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

/* ====== 内容区 ====== */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* ====== 模块面板 ====== */
.module-panel { display: none; }
.module-panel.active { display: block; }

/* ====== Pipeline Timeline ====== */
.pipeline-timeline {
    display: flex;
    gap: 0;
    background: #fff;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    overflow-x: auto;
}

.pipeline-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    white-space: nowrap;
    font-size: 13px;
    color: var(--text-muted);
    position: relative;
}

.pipeline-step:not(:last-child)::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    width: 16px;
    height: 2px;
    background: var(--border);
}

.pipeline-step .step-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    background: #f0f2f5;
    flex-shrink: 0;
}

.pipeline-step.pending .step-icon { background: #f0f2f5; color: var(--text-muted); }
.pipeline-step.running .step-icon {
    background: #e3f2fd; color: var(--info);
    animation: pulse 1.5s infinite;
}
.pipeline-step.done .step-icon { background: #e8f5e9; color: var(--success); }
.pipeline-step.error .step-icon { background: #ffebee; color: var(--error); }

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ====== Console ====== */
.console-card {
    background: #1e1e2e;
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.console-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.console-header .title {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.console-body {
    padding: 12px 16px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.7;
    color: #cdd6f4;
}

.console-body .log-line { white-space: pre-wrap; word-break: break-all; }
.console-body .log-line.error { color: #f38ba8; }
.console-body .log-line.info { color: #89b4fa; }
.console-body .log-line.success { color: #a6e3a1; }
.console-body .empty { color: rgba(255,255,255,0.2); text-align: center; padding: 30px; font-size: 13px; }

/* ====== 输入区 ====== */
.input-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

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

.input-card textarea,
.input-card input[type="text"],
.input-card select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    resize: vertical;
    transition: border-color 0.15s;
}

.input-card textarea:focus,
.input-card input[type="text"]:focus,
.input-card select:focus {
    border-color: var(--primary);
}

.input-card textarea { min-height: 80px; max-height: 200px; }

.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.form-row > * { flex: 1; }

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
}

.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
    padding: 8px 16px;
    background: #f0f2f5;
    color: var(--text-secondary);
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

.btn-secondary:hover { background: #e4e7ec; }

/* ====== 结果区 ====== */
.result-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.result-card .result-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.result-text {
    white-space: pre-wrap;
    line-height: 1.8;
    font-size: 14px;
    max-height: 400px;
    overflow-y: auto;
    padding: 12px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.result-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* ====== 素材管理 ====== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    padding: 8px 0;
}

.gallery-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 1;
    background: #e8ecf1;
    border: 2px solid transparent;
    transition: border-color 0.15s, transform 0.15s;
}

.gallery-item:hover { transform: translateY(-2px); }
.gallery-item.selected { border-color: var(--primary); }

.gallery-item img {
    width: 100%; height: 100%;
    object-fit: cover;
}

.gallery-item .check {
    position: absolute;
    top: 6px; left: 6px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: rgba(0,0,0,0.3);
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #fff;
    transition: background 0.15s;
}

.gallery-item.selected .check { background: var(--primary); }

.gallery-item .img-name {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 4px 6px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 文件夹列表 */
.folder-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.folder-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid var(--border);
}

.folder-row:hover { background: #f5f7fa; }
.folder-row .folder-icon { font-size: 20px; }
.folder-row .folder-name { flex: 1; font-size: 14px; font-weight: 500; }
.folder-row .folder-meta { font-size: 12px; color: var(--text-muted); }

/* 灯箱 */
.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.lightbox-overlay.show { display: flex; }

.lightbox-overlay img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 8px;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: 20px; right: 20px;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ====== 模型配置弹窗 ====== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 900;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-overlay.show { display: flex; }

.modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

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

.modal-header h2 { font-size: 16px; }

.modal-body { padding: 20px; }

.modal-body .form-group {
    margin-bottom: 16px;
}

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

.modal-body .form-group input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
}

.modal-body .form-group input:focus { border-color: var(--primary); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

/* ====== 补充下载栏 ====== */
.download-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 12px 16px;
    background: #fff;
    border-radius: 10px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.download-bar input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
}

.download-bar input:focus { border-color: var(--primary); }

.download-bar select {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 14px;
    outline: none;
    background: #fff;
}

/* ====== Toast ====== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 10px 24px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.toast.show { opacity: 1; }

/* ====== 面包屑 ====== */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.breadcrumb span { cursor: pointer; }
.breadcrumb span:hover { color: var(--primary); }
.breadcrumb .sep { color: var(--border); }

/* ====== 空态 ====== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ====== 选中操作栏 ====== */
.selection-bar {
    display: none;
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
    padding: 12px 16px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
    align-items: center;
    justify-content: space-between;
    z-index: 10;
}

.selection-bar.show { display: flex; }

.selection-bar .info { font-size: 14px; color: var(--text-secondary); }

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

/* ====== 响应式 ====== */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar .label, .sidebar .badge, .sidebar-header .subtitle { display: none; }
    .sidebar-header h1 { font-size: 14px; }
    .nav-item { padding: 10px; justify-content: center; }
    .content-area { padding: 12px; }
    .form-row { flex-direction: column; }
}
