/* EvoSub 智能字幕服務 - 橫式佈局 WordPress 友善樣式 */

/* ===== CSS Variables ===== */
:root {
    /* 深色主題 */
    --bg-dark: #0a0a0f;
    --bg-panel: #12121a;
    --bg-card: #1a1a24;
    --bg-input: #0d0d14;
    --bg-hover: #22222e;

    --text-primary: #f0f0f5;
    --text-secondary: #9898a8;
    --text-muted: #5c5c70;

    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.25);

    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.15);
    --warning: #f59e0b;
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.15);

    --border: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(99, 102, 241, 0.5);

    --font: 'Inter', 'Noto Sans TC', system-ui, sans-serif;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ===== Reset ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-dark);
    -webkit-font-smoothing: antialiased;
}

/* ===== App Layout - 橫式兩欄 ===== */
.app {
    display: grid;
    grid-template-columns: 1fr 380px;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
}

/* ===== 左側主面板 ===== */
.main-panel {
    padding: 32px 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
}

/* ===== 右側面板 ===== */
.side-panel {
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
}

/* ===== Section Header ===== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.supported-formats {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== 上傳區 ===== */
.upload-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.upload-icon {
    color: var(--text-muted);
    margin-bottom: 12px;
}

.upload-area:hover .upload-icon {
    color: var(--accent);
}

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

.upload-link {
    color: var(--accent);
    text-decoration: underline;
}

/* 已選檔案 */
.file-selected {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-top: 16px;
}

.file-icon {
    font-size: 24px;
}

.file-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.file-name {
    font-weight: 500;
    color: var(--text-primary);
}

.file-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== 選項區 ===== */
.options-row {
    display: flex;
    gap: 32px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.option-group {
    flex: 1;
}

.option-group>label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.radio-option,
.checkbox-option {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
}

.radio-option input,
.checkbox-option input[type="checkbox"] {
    accent-color: var(--accent);
}

.inline-input {
    display: flex;
    align-items: center;
    gap: 8px;
}

.inline-input input[type="number"] {
    width: 60px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    color: var(--text-primary);
    font-size: 13px;
}

.inline-input input:focus {
    outline: none;
    border-color: var(--accent);
}

/* ===== 按鈕 ===== */
.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-primary,
.btn-secondary,
.btn-accent {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-primary {
    background: var(--accent);
    color: white;
    padding: 10px 20px;
}

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

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

.btn-secondary {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 14px;
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-focus);
}

.btn-accent {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    padding: 10px 20px;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-accent:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

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

.btn-large {
    width: 100%;
    padding: 14px 24px;
    font-size: 15px;
    margin-top: 20px;
}

.btn-full {
    width: 100%;
}

/* ===== 進度區 ===== */
.progress-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.progress-title {
    font-weight: 500;
    color: var(--text-primary);
}

.progress-percent {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent);
}

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

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, #8b5cf6 100%);
    border-radius: 10px;
    width: 0%;
    transition: width 0.3s ease;
}

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

/* ===== 結果區 ===== */
.result-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

.result-content {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.tab {
    flex: 1;
    padding: 16px;
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

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

.tab.active {
    color: var(--accent);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
}

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

/* ===== 歷史紀錄 ===== */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.panel-count {
    font-size: 13px;
    color: var(--text-muted);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.history-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s ease;
}

.history-item:hover {
    background: var(--bg-hover);
}

.history-icon {
    width: 36px;
    height: 36px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.history-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

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

.status-processing {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

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

.status-pending {
    background: var(--accent-glow);
    color: var(--accent);
}

.status-gray {
    background: var(--bg-hover);
    color: var(--text-muted);
}

.status-deleting {
    background: rgba(220, 38, 38, 0.1);
    color: #ef4444;
}

.history-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.history-item:hover .history-actions {
    opacity: 1;
}

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

.empty-icon {
    font-size: 32px;
    opacity: 0.5;
    margin-bottom: 12px;
}

/* ===== 訓練面板 ===== */
.train-form {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.source-options {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.source-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

.source-option input {
    accent-color: var(--accent);
}

.form-select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
}

.form-select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-textarea {
    width: 100%;
    min-height: 120px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: 'Consolas', 'Monaco', monospace;
    resize: vertical;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.upload-small {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.upload-filename {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

/* 訓練結果 */
.train-result {
    padding: 20px;
    border-top: 1px solid var(--border);
}

.result-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.result-card.success {
    background: var(--success-bg);
}

.result-icon {
    width: 32px;
    height: 32px;
    background: var(--success);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
}

.result-info {
    display: flex;
    flex-direction: column;
}

.result-title {
    font-weight: 600;
    color: var(--success);
}

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

.result-terms {
    background: var(--bg-input);
    border-radius: var(--radius-md);
    padding: 12px;
}

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

.terms-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.term-tag {
    background: var(--accent-glow);
    color: var(--accent);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

.toast-info {
    border-left: 3px solid var(--accent);
}

/* ===== 響應式 ===== */
@media (max-width: 1024px) {
    .app {
        grid-template-columns: 1fr;
    }

    .side-panel {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        width: 380px;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 100;
    }

    .side-panel.open {
        transform: translateX(0);
    }
}

@media (max-width: 640px) {
    .main-panel {
        padding: 20px;
    }

    .options-row {
        flex-direction: column;
        gap: 20px;
    }

    .side-panel {
        width: 100%;
    }
}