/* Modern Jinyu Translator Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+SC:wght@400;500;700&display=swap');

/* === Variables === */
:root {
    --primary: #006A6A;
    --primary-dark: #004d4d;
    --primary-light: #008080;
    --accent: #FF6B6B;
    --success: #27ae60;
    --text-dark: #1a1a1a;
    --text-light: #ffffff;
    --text-muted: #6c757d;
    --bg-light: #f5f7fa;
    --bg-white: #ffffff;
    --border: #e1e8ed;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
}

/* === Base === */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* === Chat Container === */
.chat-container {
    width: 95%;
    max-width: 800px;
    background: var(--bg-white);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    height: 92vh;
    max-height: 850px;
    overflow: hidden;
    animation: slideUp 0.4s ease-out;
}

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

/* === Header === */
.chat-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--text-light);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.header-content {
    display: flex;
    align-items: center;
    z-index: 1;
}

.logo {
    height: 48px;
    width: auto;
    margin-right: 16px;
    border-radius: 10px;
    background: white;
    padding: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05) rotate(2deg);
}

.chat-header h1 {
    font-size: 1.5em;
    font-weight: 600;
    letter-spacing: -0.5px;
}

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

/* === Mode Toggle === */
.mode-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 14px;
    border-radius: 24px;
    backdrop-filter: blur(10px);
}

.mode-label {
    color: var(--text-light);
    font-size: 0.9em;
    font-weight: 500;
}

.switch {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 30px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.3);
    transition: 0.4s;
    border-radius: 30px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
    transition: 0.4s;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
    background: #2196F3;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* === Clear Button === */
.clear-btn {
    color: var(--text-light);
    padding: 10px;
    border-radius: 10px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    text-decoration: none;
}

.clear-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.clear-btn svg {
    transition: transform 0.3s ease;
}

.clear-btn:hover svg {
    transform: rotate(10deg);
}

/* === Chat Box === */
.chat-box {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.chat-box::-webkit-scrollbar {
    width: 6px;
}

.chat-box::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

/* === Welcome Screen === */
.welcome {
    text-align: center;
    padding: 60px 20px;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.welcome-icon {
    font-size: 4em;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.welcome h2 {
    font-size: 1.8em;
    color: var(--primary);
    margin-bottom: 10px;
}

.welcome p {
    color: var(--text-muted);
    font-size: 1.1em;
    margin-bottom: 30px;
}

.tips {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    margin-top: 30px;
}

.tip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #f0f4f8 0%, #e9ecef 100%);
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 0.9em;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease;
}

.tip:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.tip-icon {
    font-size: 1.3em;
}

/* === Messages === */
.message {
    margin-bottom: 16px;
    padding: 14px 20px;
    border-radius: 18px;
    line-height: 1.6;
    max-width: 80%;
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
    animation: messageSlide 0.3s ease-out;
    transition: transform 0.2s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.user-msg {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--text-light);
    margin-left: auto;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}

.bot-msg {
    background: linear-gradient(135deg, #f0f4f8 0%, #e9ecef 100%);
    color: var(--text-dark);
    margin-right: auto;
    border-bottom-left-radius: 4px;
    white-space: pre-wrap;
    font-family: 'Inter', 'Noto Sans SC', sans-serif;
}

/* === Chinese Text === */
.chinese-text {
    color: #D32F2F;
    font-weight: 600;
    position: relative;
    cursor: pointer;
    background: rgba(211, 47, 47, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-family: 'Noto Sans SC', sans-serif;
}

.chinese-text:hover {
    background: rgba(211, 47, 47, 0.2);
    transform: translateY(-1px);
}

.chinese-text:hover::after {
    content: "📋 Click để copy";
    position: absolute;
    background: #2c3e50;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    z-index: 10;
    box-shadow: var(--shadow-md);
}

.copy-feedback {
    position: absolute;
    background: var(--success);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    z-index: 10;
    box-shadow: var(--shadow-md);
    font-weight: 600;
}

/* === Input Area === */
.input-area {
    display: flex;
    align-items: flex-end;
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-white);
    gap: 12px;
}

.input-area textarea {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: 24px;
    resize: none;
    font-size: 1em;
    line-height: 1.5;
    min-height: 24px;
    max-height: 150px;
    overflow-y: auto;
    background: var(--bg-white);
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
}

.input-area textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 106, 106, 0.1);
}

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

.input-area button {
    padding: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--text-light);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    width: 52px;
    height: 52px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.input-area button:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-md);
}

.input-area button:active {
    transform: translateY(0) scale(0.98);
}

.input-area button:disabled {
    background: #a0a0a0;
    cursor: not-allowed;
    opacity: 0.6;
}

.input-area button svg {
    transition: transform 0.3s ease;
}

.input-area button:hover:not(:disabled) svg {
    transform: translateX(2px);
}

/* === Loading === */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 12px;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9em;
    background: var(--bg-white);
}

.spinner {
    border: 3px solid rgba(0, 106, 106, 0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 0.8s linear infinite;
}

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

/* === Modal === */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--bg-white);
    padding: 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s ease-out;
}

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

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    color: var(--text-muted);
    font-size: 32px;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-btn:hover {
    color: var(--accent);
    transform: rotate(90deg);
}

.modal-content h3 {
    color: #D32F2F;
    margin-bottom: 15px;
}

.modal-content p {
    line-height: 1.6;
}

/* === Responsive - Tablet === */
@media (max-width: 768px) {
    .chat-container {
        max-width: 95%;
        height: 95vh;
    }
    
    .chat-header h1 {
        font-size: 1.3em;
    }
    
    .message {
        max-width: 85%;
    }
}

/* === Responsive - Mobile === */
@media (max-width: 600px) {
    body {
        font-size: 14px;
        padding: 0;
    }
    
    .chat-container {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .chat-header {
        padding: 14px 16px;
        border-radius: 0;
        flex-wrap: wrap;
    }
    
    .logo {
        height: 40px;
        margin-right: 12px;
    }
    
    .chat-header h1 {
        font-size: 1.1em;
    }
    
    .mode-toggle {
        padding: 6px 10px;
        font-size: 0.85em;
    }
    
    .switch {
        width: 50px;
        height: 26px;
    }
    
    .slider:before {
        height: 20px;
        width: 20px;
        left: 3px;
        bottom: 3px;
    }
    
    input:checked + .slider:before {
        transform: translateX(24px);
    }
    
    .chat-box {
        padding: 16px;
    }
    
    .welcome {
        padding: 40px 16px;
    }
    
    .welcome h2 {
        font-size: 1.5em;
    }
    
    .tips {
        flex-direction: column;
        gap: 12px;
    }
    
    .message {
        padding: 10px 14px;
        max-width: 90%;
        font-size: 0.95em;
    }
    
    .input-area {
        padding: 12px 16px;
        gap: 8px;
    }
    
    .input-area textarea {
        padding: 10px 14px;
        font-size: 0.95em;
        max-height: 120px;
    }
    
    .input-area button {
        width: 44px;
        height: 44px;
    }
    
    .modal-content {
        width: 95%;
        padding: 20px;
    }
}

/* === Accessibility === */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
