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

/* CSS 變數 */
:root {
    --primary-color: #4A90E2;
    --secondary-color: #7ED321;
    --accent-color: #BD10E0;
    --background-color: #F8F9FA;
    --surface-color: #FFFFFF;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #E1E5E9;
    --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.15);
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 深色模式 */
[data-theme="dark"] {
    --background-color: #1a1a1a;
    --surface-color: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #999999;
    --border-color: #404040;
}

/* 基礎樣式 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
}

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

/* 頂部工具欄 */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-color);
    padding: 16px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
}

.toolbar-left,
.toolbar-right {
    display: flex;
    gap: 12px;
}

.tool-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.tool-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

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

/* 翻譯結果區 */
.result-section {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.result-container {
    padding: 24px;
}

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

.result-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-action {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--secondary-color);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-action:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-medium);
}

.result-content {
    min-height: 80px;
    font-size: 18px;
    line-height: 1.6;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

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

/* 語言選擇區 */
.language-section {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    padding: 20px;
}

.language-selector {
    display: flex;
    align-items: center;
    gap: 16px;
}

.language-select {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--surface-color);
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
}

.language-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.swap-btn {
    width: 48px;
    height: 48px;
    border: 2px solid var(--border-color);
    background: var(--surface-color);
    color: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.swap-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: rotate(180deg);
}

/* 文本輸入區 */
.input-section {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.input-container {
    padding: 24px;
}

.input-text {
    width: 100%;
    min-height: 120px;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--background-color);
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    transition: var(--transition);
}

.input-text:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.input-text::placeholder {
    color: var(--text-muted);
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
}

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

.input-actions {
    display: flex;
    gap: 12px;
}

.action-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.action-btn.primary:hover {
    background: #3a7bc8;
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.action-btn.secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

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

/* 底部品牌區 */
.footer {
    text-align: center;
    padding: 32px 0;
    margin-top: auto;
}

.brand-title {
    font-size: 28px;
    color: var(--primary-color);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.brand-subtitle {
    color: var(--text-muted);
    font-size: 16px;
}

/* 載入動畫 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    background: var(--surface-color);
    padding: 32px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow-medium);
}

.loading-spinner i {
    font-size: 32px;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.loading-spinner span {
    display: block;
    color: var(--text-primary);
    font-weight: 600;
}

/* 彈窗樣式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
}

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

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

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
}

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

.modal-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

/* 歷史記錄 */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.history-item {
    padding: 16px;
    background: var(--background-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-languages {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

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

.history-content {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: center;
}

.history-source,
.history-target {
    font-size: 14px;
    line-height: 1.4;
}

.history-source {
    color: var(--text-secondary);
}

.history-target {
    color: var(--text-primary);
    font-weight: 500;
}

.history-arrow {
    color: var(--primary-color);
    font-size: 16px;
}

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

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* 設定項目 */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-item label {
    color: var(--text-primary);
    font-weight: 500;
}

/* 切換開關 */
.toggle {
    position: relative;
    width: 50px;
    height: 26px;
    appearance: none;
    background: var(--border-color);
    border-radius: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.toggle:checked {
    background: var(--primary-color);
}

.toggle::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
}

.toggle:checked::before {
    transform: translateX(24px);
}

/* 響應式設計 */
@media (max-width: 768px) {
    .container {
        padding: 16px;
        gap: 20px;
    }
    
    .toolbar {
        padding: 12px 16px;
    }
    
    .toolbar-left,
    .toolbar-right {
        gap: 8px;
    }
    
    .tool-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .language-selector {
        flex-direction: column;
        gap: 12px;
    }
    
    .swap-btn {
        width: 40px;
        height: 40px;
        transform: rotate(90deg);
    }
    
    .swap-btn:hover {
        transform: rotate(270deg);
    }
    
    .input-footer {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }
    
    .input-actions {
        justify-content: center;
    }
    
    .brand-title {
        font-size: 24px;
    }
    
    .modal-content {
        margin: 20px;
    }
    
    .history-content {
        grid-template-columns: 1fr;
        gap: 8px;
        text-align: center;
    }
    
    .history-arrow {
        transform: rotate(90deg);
    }
}

@media (max-width: 480px) {
    .container {
        padding: 12px;
        gap: 16px;
    }
    
    .result-container,
    .input-container {
        padding: 20px;
    }
    
    .language-section {
        padding: 16px;
    }
    
    .input-text {
        min-height: 100px;
        font-size: 16px; /* 防止iOS縮放 */
    }
    
    .action-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* 動畫效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

/* 語音輸入動畫 */
.voice-recording {
    animation: pulse 1.5s infinite;
}

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

/* 無障礙設計 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 高對比度模式 */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-muted: #666666;
    }
}

