/* 优化样式 - 白色背景横向布局 */

/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: #333;
    background: #ffffff;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 - 白色背景 */
header {
    background: #ffffff;
    padding: 20px 30px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 30px;
    border: 1px solid #e8e8e8;
}

header h1 {
    color: #2c3e50;
    font-size: 2.2em;
    margin-bottom: 15px;
    font-weight: 600;
    text-align: center;
}

nav {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nav-link {
    padding: 10px 20px;
    text-decoration: none;
    color: #666;
    border: 1px solid #ddd;
    border-radius: 20px;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.95em;
}

.nav-link:hover {
    border-color: #3498db;
    color: #3498db;
    background: #f8f9ff;
}

.nav-link.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

/* 主内容区域 - 横向布局 */
main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    align-items: start;
}

/* 翻译卡片 - 白色背景 */
.translation-card {
    background: #ffffff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8e8e8;
    height: fit-content;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 1em;
}

textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    resize: vertical;
    transition: all 0.3s ease;
    font-family: inherit;
    background: #fafafa;
}

textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    background: #ffffff;
}

.char-counter {
    text-align: right;
    margin-top: 5px;
    font-size: 0.85em;
    color: #666;
}

.language-tips {
    margin-top: 8px;
}

.language-tips small {
    color: #888;
    font-style: italic;
    font-size: 0.8em;
}

/* 表单操作按钮 */
.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: #f8f9fa;
    color: #666;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-outline {
    background: transparent;
    color: #3498db;
    border: 1px solid #3498db;
}

.btn-outline:hover {
    background: #3498db;
    color: white;
}

/* 结果区域 - 预布局 */
.results-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.result-card {
    background: #ffffff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8e8e8;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s ease;
}

.result-card.show {
    opacity: 1;
    transform: translateY(0);
}

.result-card h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.5em;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
}

.result-section {
    margin-bottom: 20px;
}

.result-section h3 {
    color: #34495e;
    margin-bottom: 10px;
    font-size: 1.1em;
    font-weight: 600;
}

.text-box {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 3px solid #3498db;
    margin-bottom: 10px;
    font-size: 15px;
    line-height: 1.6;
    min-height: 50px;
    word-wrap: break-word;
}

.original-text {
    border-left-color: #3498db;
}

.translation-text {
    border-left-color: #e74c3c;
}

.back-translation-text {
    border-left-color: #f39c12;
}

/* 相似度指示器 */
.similarity-indicator {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.similarity-indicator h3 {
    margin-bottom: 10px;
    font-size: 1.1em;
}

.similarity-bar {
    width: 100%;
    height: 16px;
    background: #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    margin: 10px 0;
}

.similarity-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b 0%, #feca57 50%, #48dbfb 100%);
    transition: width 0.5s ease;
}

.similarity-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.9em;
}

.quality-badge {
    padding: 3px 10px;
    border-radius: 15px;
    font-size: 0.8em;
    font-weight: 600;
}

.quality-good {
    background: #d4edda;
    color: #155724;
}

.quality-fair {
    background: #fff3cd;
    color: #856404;
}

.quality-poor {
    background: #f8d7da;
    color: #721c24;
}

/* 警告消息 */
.alert {
    padding: 12px 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 4px solid;
    font-size: 0.9em;
}

.alert-error {
    background: #fee;
    border-color: #f44336;
    color: #c62828;
}

/* 结果操作 */
.result-actions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* 加载动画 */
.loading-spinner {
    display: inline-block;
}

.spinner {
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
}

.spinner .path {
    stroke: white;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes dash {
    0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

/* 页脚 */
footer {
    text-align: center;
    margin-top: 40px;
    color: #666;
    font-size: 0.85em;
}

/* 复制按钮动画 */
.btn.copied {
    background: #28a745 !important;
    border-color: #28a745 !important;
    color: white !important;
}

/* 预布局占位符 */
.placeholder-section {
    background: #f8f9fa;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: #999;
    font-style: italic;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .container {
        max-width: 800px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header {
        padding: 15px 20px;
    }
    
    header h1 {
        font-size: 1.8em;
    }
    
    nav {
        gap: 6px;
    }
    
    .nav-link {
        padding: 8px 16px;
        font-size: 0.9em;
    }
    
    .translation-card,
    .result-card {
        padding: 20px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .result-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.6em;
    }
    
    .translation-card,
    .result-card {
        padding: 15px;
    }
    
    .text-box {
        padding: 12px;
        font-size: 14px;
        min-height: 40px;
    }
}

/* 复制成功消息 */
.copy-success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    z-index: 1000;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 语言检测结果 */
.language-detect {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 10px;
}

.language-detect.zh {
    background: #e3f2fd;
    color: #1976d2;
}

.language-detect.ro {
    background: #f3e5f5;
    color: #7b1fa2;
}

.language-detect.unknown {
    background: #fff3e0;
    color: #f57c00;
}

/* 历史记录样式 */
.history-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.history-item:hover {
    background: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.history-time {
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}

.history-text {
    flex: 1;
    margin-right: 15px;
}

.history-original {
    font-weight: 600;
    margin-bottom: 5px;
    color: #2c3e50;
}

.history-translation {
    color: #666;
    font-size: 14px;
}

.no-history {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 20px;
}

/* 键盘快捷键提示 */
.keyboard-shortcuts {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px;
    border-radius: 8px;
    font-size: 12px;
    z-index: 1000;
    max-width: 250px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.keyboard-shortcuts.show {
    opacity: 1;
}

.keyboard-shortcuts h4 {
    margin-bottom: 10px;
    color: #fff;
}

.keyboard-shortcuts ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.keyboard-shortcuts li {
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
}

.shortcut-key {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
}

/* 加载动画增强 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}

.loading-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.loading-spinner-large {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
}

.loading-spinner-large .spinner {
    width: 100%;
    height: 100%;
}

.loading-text {
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

/* 响应式增强 */
@media (max-width: 768px) {
    .keyboard-shortcuts {
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .copy-success-message {
        top: 10px;
        right: 10px;
        left: 10px;
    }
    
    .history-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .history-text {
        margin-right: 0;
        margin-bottom: 10px;
    }
}

/* 动画效果 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.fade-in-up {
    animation: fadeInUp 0.6s ease;
}

.fade-in-down {
    animation: fadeInDown 0.6s ease;
}

.pulse {
    animation: pulse 2s infinite;
}

/* 无障碍增强 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
    .btn-primary {
        background: #000;
        color: #fff;
    }
    
    .text-box {
        border-width: 3px;
    }
    
    .nav-link {
        border-width: 3px;
    }
}