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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: #2d5a3d;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 头部样式 */
.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5rem;
    color: #1a4d2e;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    color: #4a7c59;
    opacity: 0.9;
}

/* 主要内容区域 */
.main-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.translate-box {
    width: 100%;
    max-width: 900px;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(26, 77, 46, 0.1);
}

/* 语言选择器 */
.language-selector {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
    justify-content: center;
}

.lang-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    max-width: 200px;
}

.lang-group label {
    font-size: 0.9rem;
    color: #2d5a3d;
    font-weight: 500;
}

.lang-select {
    padding: 12px 16px;
    border: 2px solid #74c69d;
    border-radius: 12px;
    color: #2d5a3d;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.lang-select:focus {
    outline: none;
    border-color: #52b788;
    box-shadow: 0 0 0 3px rgba(116, 198, 157, 0.2);
}

.lang-select:hover {
    border-color: #52b788;
}

.swap-btn {
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    margin-top: 25px;
}

.swap-btn:hover {
    transform: rotate(180deg);
}

/* 文本区域 */
.text-areas {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

.input-section,
.output-section {
    display: flex;
    flex-direction: column;
}

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

.detected-lang,
.target-lang {
    font-size: 0.9rem;
    color: #4a7c59;
    font-weight: 500;
}

.clear-btn,
.copy-btn {
    background: none;
    border: none;
    color: #74c69d;
    cursor: pointer;
    padding: 5px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.clear-btn:hover,
.copy-btn:hover {
    color: #52b788;
}

#input-text {
    width: 100%;
    height: 200px;
    padding: 16px;
    border: 2px solid #74c69d;
    border-radius: 12px;
    font-size: 1rem;
    color: #2d5a3d;
    resize: vertical;
    transition: all 0.3s ease;
    font-family: inherit;
}

#input-text:focus {
    outline: none;
    border-color: #52b788;
    box-shadow: 0 0 0 3px rgba(116, 198, 157, 0.2);
}

#input-text::placeholder {
    color: #74c69d;
    opacity: 0.7;
}

.output-text {
    width: 100%;
    height: 200px;
    padding: 16px;
    border: 2px solid #b7e4c7;
    border-radius: 12px;
    font-size: 1rem;
    color: #2d5a3d;
    overflow-y: auto;
    line-height: 1.6;
}

.char-count {
    text-align: right;
    font-size: 0.8rem;
    color: #74c69d;
    margin-top: 5px;
}

.pronounce-section {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.pronounce-item {
    font-size: 0.9rem;
    color: #4a7c59;
    font-style: italic;
    padding: 5px 10px;
    border-radius: 8px;
    display: none;
}

.pronounce-item.show {
    display: block;
}

/* 操作按钮 */
.action-buttons {
    display: flex;
    justify-content: center;
}

.translate-btn {
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.translate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(116, 198, 157, 0.3);
}

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

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

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

.translate-btn.loading .btn-text {
    display: none;
}

.translate-btn.loading .loading-spinner {
    display: block;
}

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

/* 页脚 */
.footer {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    color: #4a7c59;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* 提示消息 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(82, 183, 136, 0.3);
}

.toast.show {
    transform: translateX(0);
}

.toast.error {
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

/* 平板适配 (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 2.2rem;
    }
    
    .translate-box {
        padding: 25px;
    }
    
    .language-selector {
        gap: 15px;
    }
    
    .text-areas {
        gap: 15px;
    }
    
    #input-text,
    .output-text {
        height: 180px;
    }
}

/* 手机端适配 (最大768px) */
@media (max-width: 767px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .translate-box {
        padding: 20px 15px;
        border-radius: 15px;
    }
    
    .language-selector {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .lang-group {
        max-width: none;
    }
    
    .swap-btn {
        align-self: center;
        margin-top: 0;
        order: 2;
    }
    
    .text-areas {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    #input-text,
    .output-text {
        height: 150px;
        font-size: 0.95rem;
    }
    
    .translate-btn {
        padding: 12px 30px;
        font-size: 1rem;
        width: 100%;
        max-width: 200px;
    }
    
    .toast {
        right: 10px;
        left: 10px;
        transform: translateY(-100%);
    }
    
    .toast.show {
        transform: translateY(0);
    }
}

/* 超小屏幕适配 (最大480px) */
@media (max-width: 480px) {
    .header h1 {
        font-size: 1.6rem;
    }
    
    .translate-box {
        padding: 15px 10px;
    }
    
    .lang-select {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    
    #input-text,
    .output-text {
        height: 120px;
        padding: 12px;
        font-size: 0.9rem;
    }
    
    .translate-btn {
        padding: 10px 25px;
        font-size: 0.95rem;
    }
}