/**
 * css/app.css
 * MiniMax H3 现代化深色质感设计系统
 */

:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.75);
    --bg-card-hover: rgba(31, 41, 55, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(99, 102, 241, 0.5);
    
    --accent-primary: #6366f1;
    --accent-hover: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.35);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-hover: #dc2626;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);
    --shadow-glow: 0 0 24px var(--accent-glow);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.1) 0px, transparent 50%);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 24px 16px;
    display: flex;
    justify-content: center;
}

.app-container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* 顶部导航与品牌 */
.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    font-size: 28px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f46e5, #9333ea);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.brand-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #ffffff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.system-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}
.status-dot.offline {
    background-color: var(--danger);
    box-shadow: 0 0 8px var(--danger);
}

/* 主内容两栏栅格 */
.main-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 24px;
}

@media (max-width: 960px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

/* 卡片容器 */
.card-panel {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

/* 表单组件 */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

.form-input, .form-textarea, .form-select {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 14px;
    transition: all 0.2s ease;
    outline: none;
}

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

.form-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

/* 提示词预设标签 */
.prompt-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.prompt-tag {
    font-size: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.prompt-tag:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--accent-primary);
    color: #fff;
}

/* 参数两列网格 */
.params-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* 创作模式选择器 */
.mode-selector-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.mode-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 640px) {
    .mode-cards-grid {
        grid-template-columns: 1fr;
    }
}

.mode-card {
    position: relative;
    background: rgba(15, 23, 42, 0.6);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 6px;
    user-select: none;
}

.mode-card:hover {
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(30, 41, 59, 0.7);
    transform: translateY(-2px);
}

.mode-card.active {
    border-color: var(--accent-primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.08));
    box-shadow: 0 0 16px var(--accent-glow);
}

.mode-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mode-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-primary);
}

.mode-icon {
    font-size: 16px;
}

.mode-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.mode-badge-primary {
    background: rgba(99, 102, 241, 0.25);
    color: #a5b4fc;
    border-color: rgba(99, 102, 241, 0.45);
    font-weight: 600;
}

.mode-card-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
}

/* 素材插槽区 */
.slots-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.slots-grid-images {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.slot-card {
    position: relative;
    background: rgba(15, 23, 42, 0.5);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.slot-card:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.08);
    transform: translateY(-2px);
}

.slot-card.has-file {
    border-style: solid;
    border-color: rgba(16, 185, 129, 0.4);
    background: #000;
}

.slot-card.dragging {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.2);
    box-shadow: 0 0 12px var(--accent-glow);
}

.slot-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.slot-empty-icon {
    font-size: 20px;
    margin-bottom: 4px;
    opacity: 0.6;
}

.slot-label {
    font-size: 11px;
    color: var(--text-muted);
}

.slot-remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: rgba(239, 68, 68, 0.85);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.slot-card:hover .slot-remove-btn {
    opacity: 1;
}

/* 首帧专属单图上传大卡片 */
.first-frame-slot-card {
    position: relative;
    background: rgba(15, 23, 42, 0.55);
    border: 2px dashed rgba(255, 255, 255, 0.16);
    border-radius: var(--radius-md);
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 24px 16px;
    text-align: center;
}

.first-frame-slot-card:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.08);
    transform: translateY(-2px);
}

.first-frame-slot-card.dragging {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.2);
    box-shadow: 0 0 16px var(--accent-glow);
}

.first-frame-slot-card.has-file {
    border-style: solid;
    border-color: rgba(16, 185, 129, 0.5);
    background: #000;
    padding: 0;
    height: 260px;
}

.first-frame-slot-card .slot-preview-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #050811;
}

.first-frame-slot-card .slot-label-main {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 8px;
    margin-bottom: 4px;
}

.first-frame-slot-card .slot-label-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.first-frame-slot-card.has-file .slot-remove-btn {
    opacity: 1;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    font-size: 14px;
}

.first-frame-slot-card.has-file:hover .slot-remove-btn {
    transform: scale(1.1);
}

.badge-mode {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    margin-right: 4px;
}
.badge-mode.first-frame {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.35);
}
.badge-mode.all-round {
    background: rgba(168, 85, 247, 0.2);
    color: #d8b4fe;
    border: 1px solid rgba(168, 85, 247, 0.35);
}

/* 音频插槽网格 */
.slots-grid-audios {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.audio-slot-card {
    position: relative;
    background: rgba(15, 23, 42, 0.5);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 80px;
}

.audio-slot-card:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.08);
}

.audio-slot-card.has-file {
    border-style: solid;
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.08);
}

/* 操作按钮 */
.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.btn {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
    color: #fff;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover:not(:disabled) {
    opacity: 0.95;
    transform: translateY(-1px);
    box-shadow: 0 0 28px rgba(99, 102, 241, 0.5);
}

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

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

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

/* 进度与状态看板 */
.status-tracker {
    display: none;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.status-tracker.active {
    display: flex;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #10b981);
    border-radius: 4px;
    transition: width 0.4s ease;
}

.status-meta {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
}

/* 多任务并发活动卡片池 */
.active-tasks-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 10px;
}

.active-task-card {
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.25s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    position: relative;
    overflow: hidden;
}

.active-task-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-primary);
    border-radius: 4px 0 0 4px;
}

.active-task-card.status-queuing::before,
.active-task-card.status-queued::before {
    background: var(--warning);
}

.badge-status.queued {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.active-task-card.status-success::before {
    background: var(--success);
}

.active-task-card.status-failed::before {
    background: var(--danger);
}

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

.active-task-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.active-task-id {
    font-family: monospace;
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 600;
}

.active-task-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-task-cancel {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-task-cancel:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #fff;
}

.active-task-prompt {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.active-task-video-preview {
    margin-top: 6px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    max-height: 220px;
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.active-task-video-preview video {
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    display: block;
}

.active-task-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

/* 结果展示卡片 */
.result-box {
    display: none;
    flex-direction: column;
    gap: 16px;
}

.result-box.active {
    display: flex;
}

.video-player-wrapper {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    aspect-ratio: 16 / 9;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.result-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

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

/* 错误提示条 */
.error-banner {
    display: none;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    font-size: 14px;
    line-height: 1.5;
}

.error-banner.active {
    display: block;
}

/* 当前任务 ID 浮动徽标 */
.current-task-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-primary);
    margin-top: 4px;
}

.current-task-bar strong {
    color: var(--accent-primary);
    font-family: monospace;
    font-size: 13px;
    letter-spacing: 0.5px;
}

.btn-copy-id {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy-id:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

/* 历史任务与失联找回面板 */
.history-panel {
    display: flex;
    flex-direction: column;
    margin-top: 4px;
}

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

.btn-link {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s;
}

.btn-link:hover {
    color: var(--danger);
}

.recovery-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.recovery-input {
    flex: 1;
    font-family: monospace;
    font-size: 13px;
}

.recovery-btn {
    white-space: nowrap;
    padding: 0 16px;
}

.history-table-container {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    max-height: 260px;
    overflow-y: auto;
}

.history-empty {
    padding: 24px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

.history-items-list {
    display: flex;
    flex-direction: column;
}

.history-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.15s ease;
}

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

.history-item-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.history-item-main {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.history-item-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-task-id {
    font-family: monospace;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.history-item-prompt {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-time {
    font-size: 11px;
    color: var(--text-muted);
}

.history-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.badge-status {
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.badge-status.running {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.4);
}

.badge-status.queued {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-status.success {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-status.failed {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.badge-status.cancelled {
    background: rgba(148, 163, 184, 0.2);
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.4);
}

.btn-history-action {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-history-action:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}

.btn-history-del {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 4px;
}

.btn-history-del:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

