/* ==========================================================================
   AI 智能翻译 Web 终端 - 现代化 CSS 设计系统
   ========================================================================== */

:root {
    /* 颜色变量 - 默认暗黑主题 */
    --bg-main: #0b0f19;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(31, 41, 55, 0.8);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(99, 102, 241, 0.4);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --accent-primary: #6366f1;
    --accent-primary-hover: #4f46e5;
    --accent-secondary: #8b5cf6;
    --accent-cyan: #06b6d4;
    
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.25);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 9999px;

    --font-sans: 'Plus Jakarta Sans', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
    --font-mono: 'Fira Code', monospace;

    --glass-blur: blur(16px);
}

/* 明亮主题颜色 */
body.light-theme {
    --bg-main: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(241, 245, 249, 0.9);
    --border-color: rgba(0, 0, 0, 0.08);
    --border-highlight: rgba(99, 102, 241, 0.5);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.06);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

/* 基础重置 */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 24px;
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(6, 182, 212, 0.1) 0%, transparent 40%);
    background-attachment: fixed;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 主容器 */
.app-container {
    width: 100%;
    max-width: 1280px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ==========================================================================
   Header 样式
   ========================================================================== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

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

.logo-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #ffffff;
    box-shadow: var(--shadow-glow);
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.model-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 4px 8px 4px 12px;
}

.model-icon {
    color: var(--accent-cyan);
    font-size: 0.95rem;
}

.custom-select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    max-width: 180px;
}

.custom-select option {
    background-color: #1e293b;
    color: #f8fafc;
}

body.light-theme .custom-select option {
    background-color: #ffffff;
    color: #0f172a;
}

/* 按钮基础样式 */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.45);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: var(--border-color);
}

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

.btn-danger-outline {
    background: transparent;
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

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

.btn.sm, .btn-danger-outline.sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    transform: scale(1.05);
}

.icon-btn.sm {
    width: 30px;
    height: 30px;
    font-size: 0.82rem;
}

/* ==========================================================================
   工具栏 样式
   ========================================================================== */
.translator-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}

.lang-selector-group, .style-selector-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 200px;
}

.lang-select {
    width: 100%;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

body.light-theme .lang-select {
    background: rgba(0, 0, 0, 0.04);
}

.lang-select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.lang-select option {
    background-color: #1e293b;
    color: #f8fafc;
}

body.light-theme .lang-select option {
    background-color: #ffffff;
    color: #0f172a;
}

.swap-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.swap-btn:hover {
    background: var(--accent-primary);
    color: #ffffff;
    transform: rotate(180deg) scale(1.1);
    box-shadow: var(--shadow-glow);
}

.style-icon {
    color: var(--accent-secondary);
    font-size: 1.1rem;
}

/* ==========================================================================
   核心翻译双栏卡片
   ========================================================================== */
.translation-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

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

.card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    min-height: 380px;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.card:focus-within {
    border-color: var(--border-highlight);
    box-shadow: var(--shadow-glow);
}

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

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.text-accent {
    color: var(--accent-cyan);
}

.card-tools {
    display: flex;
    gap: 8px;
}

.text-tool-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.text-tool-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.card-body {
    flex: 1;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    position: relative;
}

textarea#source-text {
    width: 100%;
    height: 100%;
    min-height: 220px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 1.05rem;
    line-height: 1.6;
    resize: none;
}

textarea#source-text::placeholder {
    color: var(--text-muted);
}

.target-output {
    width: 100%;
    height: 100%;
    min-height: 220px;
    font-family: var(--font-sans);
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-y: auto;
}

.target-output.placeholder-text {
    color: var(--text-muted);
    font-style: italic;
}

/* 打字机游标动画 */
.target-output.streaming::after {
    content: '▋';
    display: inline-block;
    color: var(--accent-cyan);
    animation: blink 0.8s infinite;
    margin-left: 2px;
}

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

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.05);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

.char-count, .meta-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.time-tag {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
}

.action-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 状态指示器 */
.status-indicator {
    font-size: 0.78rem;
    color: var(--accent-cyan);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
}

.status-indicator.hidden {
    display: none;
}

.spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(6, 182, 212, 0.3);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   历史记录区域
   ========================================================================== */
.history-section {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.history-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.history-title i {
    color: var(--accent-primary);
}

.history-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 4px 12px;
}

.search-box i {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    padding: 4px 0;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 4px;
}

.history-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    transition: all 0.2s ease;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(99, 102, 241, 0.3);
}

.history-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-tag {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.history-texts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    font-size: 0.88rem;
}

.history-source {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.history-item-actions {
    display: flex;
    gap: 6px;
}

.empty-history {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}

/* ==========================================================================
   模态弹窗 Modal 样式
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.25s ease;
}

.modal-backdrop.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 520px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transform: translateY(0);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-backdrop.hidden .modal-card {
    transform: translateY(-20px);
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

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

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-with-icon {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    gap: 10px;
}

.input-with-icon i {
    color: var(--text-muted);
}

.input-with-icon input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
}

.toggle-eye-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

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

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.connection-status {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.connection-status.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.connection-status.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.connection-status.hidden {
    display: none;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.1);
}

/* Toast 提示浮层 */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
}

.toast {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 0.88rem;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.success i { color: var(--success-color); }
.toast.info i { color: var(--accent-cyan); }
.toast.error i { color: var(--danger-color); }

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
