:root {
    --primary-color: #4a90e2;
    --secondary-color: #50e3c2;
    --accent-color: #f5a623;
    --bg-color: #1a1a2e;
    --card-bg: #16213e;
    --text-color: #eee;
    --text-muted: #888;
    --border-color: #0f3460;
    --success-color: #4caf50;
    --error-color: #f44336;
}

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

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

/* Header */
.header {
    background: var(--card-bg);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.header h1 {
    font-size: 24px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Main Layout */
.main-container {
    display: flex;
    height: calc(100vh - 70px);
}

.preview-panel {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Video Container */
.video-container {
    position: relative;
    width: 100%;
    max-width: 960px;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    margin: 0 auto;
}

#videoCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Subtitle Overlay */
.subtitle-overlay {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    padding: 15px 30px;
    border-radius: 10px;
    max-width: 90%;
    text-align: center;
    font-size: 24px;
    opacity: 0;
    transition: opacity 0.3s;
}

.subtitle-overlay.visible {
    opacity: 1;
}

/* Controls */
.controls {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--card-bg);
    border-radius: 10px;
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
}

.control-btn {
    background: var(--border-color);
    border: none;
    color: var(--text-color);
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
}

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

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

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

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

/* Progress Bar */
.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    cursor: pointer;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0%;
    border-radius: 4px;
}

.time-display {
    font-size: 14px;
    color: var(--text-muted);
    min-width: 100px;
    text-align: center;
}

/* Control Panel */
.control-panel {
    width: 450px;
    background: var(--card-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

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

.panel-section h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--text-muted);
}

/* Input Group */
.input-group textarea {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
}

.generate-btn {
    width: 100%;
    padding: 15px;
    margin-top: 10px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

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

/* Scenes Container */
.scenes-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* Scene Card */
.scene-card {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.scene-card:hover {
    border-color: var(--primary-color);
    transform: translateX(3px);
}

.scene-card.active {
    border-color: var(--secondary-color);
    box-shadow: 0 0 20px rgba(80,227,194,0.3);
}

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

.scene-number {
    background: var(--primary-color);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
}

.scene-type {
    font-size: 11px;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.scene-duration {
    font-size: 12px;
    color: var(--accent-color);
    font-weight: 500;
}

/* Scene Preview */
.scene-preview {
    background: #0d1117;
    border-radius: 8px;
    padding: 14px;
    margin: 10px 0;
    font-size: 15px;
    line-height: 1.7;
    max-height: 180px;
    overflow: hidden;
}

.scene-preview .highlight {
    color: #ff6b6b;
    font-weight: bold;
}

.scene-preview .comparison-preview {
    display: flex;
    gap: 10px;
    align-items: center;
}

.scene-preview .comparison-left,
.scene-preview .comparison-right {
    flex: 1;
    padding: 8px;
    border-radius: 6px;
    text-align: center;
    font-size: 12px;
}

.scene-preview .comparison-left {
    background: rgba(244, 67, 54, 0.2);
    border: 1px solid #f44336;
}

.scene-preview .comparison-right {
    background: rgba(76, 175, 80, 0.2);
    border: 1px solid #4caf50;
}

.scene-preview .comparison-arrow {
    color: var(--accent-color);
    font-size: 18px;
    font-weight: bold;
}

.scene-preview .transform-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.scene-preview .transform-item {
    padding: 4px 10px;
    background: rgba(74, 144, 226, 0.2);
    border-radius: 4px;
    border: 1px solid var(--primary-color);
}

.scene-preview .transform-arrow {
    color: var(--accent-color);
    font-weight: bold;
}

.scene-preview .list-preview {
    padding-left: 20px;
}

.scene-preview .list-preview li {
    margin: 4px 0;
}

/* Scene Narration */
.scene-narration {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 10px;
    font-style: italic;
    padding: 8px 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 6px;
}

/* Scene HTML Toggle */
.scene-html-toggle {
    font-size: 11px;
    color: var(--primary-color);
    cursor: pointer;
    margin-top: 8px;
    display: inline-block;
}

.scene-html-toggle:hover {
    text-decoration: underline;
}

.scene-html-code {
    display: none;
    margin-top: 8px;
    padding: 10px;
    background: #0d1117;
    border-radius: 6px;
    font-family: 'Consolas', monospace;
    font-size: 11px;
    color: #8b949e;
    max-height: 300px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.scene-html-code.visible {
    display: block;
}

/* HTML 代码编辑器样式 */
.scene-html-editor {
    display: none;
    flex-direction: column;
    gap: 10px;
}

.scene-html-editor.visible {
    display: flex;
}

.html-code-textarea {
    width: 100%;
    min-height: 150px;
    max-height: 250px;
    padding: 10px;
    background: #0d1117;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    color: #e6edf3;
    resize: vertical;
    line-height: 1.5;
    tab-size: 2;
}

.html-code-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.html-editor-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.html-editor-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.html-editor-btn.save-btn {
    background: var(--border-color);
    color: var(--text-color);
}

.html-editor-btn.save-btn:hover {
    background: var(--primary-color);
}

.html-editor-btn.preview-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.html-editor-btn.preview-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Status Bar */
.status-bar {
    padding: 10px 20px;
    background: var(--border-color);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-indicator.loading {
    background: var(--accent-color);
    animation: pulse 1s infinite;
}

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

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

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

/* Mode Tabs */
.mode-tabs {
    display: flex;
    margin-bottom: 15px;
    background: var(--bg-color);
    border-radius: 8px;
    padding: 4px;
}

.mode-tab {
    flex: 1;
    padding: 10px 15px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s;
}

.mode-tab:hover {
    color: var(--text-color);
}

.mode-tab.active {
    background: var(--primary-color);
    color: white;
}

.mode-description {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding: 8px;
    background: rgba(0,0,0,0.2);
    border-radius: 6px;
    line-height: 1.5;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.loading-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

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

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

.loading-text {
    margin-top: 20px;
    font-size: 18px;
}

.loading-progress {
    margin-top: 10px;
    font-size: 14px;
    color: var(--text-muted);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
}

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

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
}

/* Form */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 14px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Responsive */
@media (max-width: 1200px) {
    .main-container {
        flex-direction: column;
    }
    
    .control-panel {
        width: 100%;
        height: 50%;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }
}
