/* Reset và Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

/* Animated background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, rgba(255,255,255,0.1) 25%, transparent 25%), 
                linear-gradient(-45deg, rgba(255,255,255,0.1) 25%, transparent 25%), 
                linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.1) 75%), 
                linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.1) 75%);
    background-size: 60px 60px;
    background-position: 0 0, 0 30px, 30px -30px, -30px 0px;
    animation: moveBackground 20s linear infinite;
    z-index: -1;
}

@keyframes moveBackground {
    0% { transform: translateX(0) translateY(0); }
    100% { transform: translateX(60px) translateY(60px); }
}

/* Chat Container */
.chat-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 900px;
    height: 700px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #4285f4 0%, #34a853 50%, #ea4335 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px 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: shine 3s ease-in-out infinite;
}

@keyframes shine {
    0%, 100% { transform: translateX(-100%); }
    50% { transform: translateX(100%); }
}

.header-content h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-content p {
    opacity: 0.9;
    font-size: 14px;
    font-weight: 400;
}

/* Model Selector */
.model-selector {
    z-index: 10;
}

.model-selector select {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    color: white;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.model-selector select:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.model-selector select option {
    background: #fff;
    color: #333;
    padding: 8px;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: linear-gradient(to bottom, transparent, rgba(247, 250, 252, 0.5));
}

.message {
    max-width: 85%;
    padding: 16px 20px;
    border-radius: 20px;
    line-height: 1.6;
    word-wrap: break-word;
    animation: slideIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    font-size: 15px;
}

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

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, #4285f4 0%, #34a853 100%);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
}

.ai-message {
    align-self: flex-start;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    color: #202124;
    border-bottom-left-radius: 6px;
    border: 1px solid #e8eaed;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.loading {
    align-self: flex-start;
    background: linear-gradient(90deg, #f1f3f4, #e8eaed, #f1f3f4);
    background-size: 200% 100%;
    color: #5f6368;
    font-style: italic;
    animation: loading 2s ease-in-out infinite;
    border-radius: 20px;
    border-bottom-left-radius: 6px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Empty State */
.empty-state {
    text-align: center;
    color: #5f6368;
    padding: 60px 20px;
    max-width: 500px;
    margin: 0 auto;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 20px;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.empty-state h3 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #202124;
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 30px;
    line-height: 1.5;
}

.suggestions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.suggestion-btn {
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
    border: 2px solid #e8eaed;
    border-radius: 16px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    color: #5f6368;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
    text-align: center;
}

.suggestion-btn:hover {
    background: linear-gradient(135deg, #4285f4 0%, #34a853 100%);
    color: white;
    border-color: transparent;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
}

/* Chat Input */
.chat-input {
    padding: 20px 24px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(232, 234, 237, 0.8);
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.input-group {
    flex: 1;
    position: relative;
}

#messageInput {
    width: 100%;
    min-height: 56px;
    max-height: 140px;
    padding: 16px 60px 16px 20px;
    border: 2px solid #e8eaed;
    border-radius: 28px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: all 0.3s ease;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

#messageInput:focus {
    border-color: #4285f4;
    box-shadow: 0 0 0 4px rgba(66, 133, 244, 0.1), 0 2px 8px rgba(0, 0, 0, 0.1);
}

.send-button {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #4285f4 0%, #34a853 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.3);
}

.send-button:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(66, 133, 244, 0.4);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.input-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-btn {
    width: 40px;
    height: 40px;
    background: rgba(95, 99, 104, 0.1);
    border: 1px solid rgba(95, 99, 104, 0.2);
    border-radius: 12px;
    color: #5f6368;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: rgba(95, 99, 104, 0.2);
    border-color: rgba(95, 99, 104, 0.3);
    transform: translateY(-1px);
}

/* Error Message */
.error-message {
    background: linear-gradient(135deg, #fee8e6 0%, #fce8e6 100%);
    color: #d93025;
    border: 1px solid #fce8e6;
    padding: 16px 20px;
    border-radius: 16px;
    margin: 10px 0;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideIn 0.3s ease-out;
}

.error-message::before {
    content: '⚠️';
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    .chat-container {
        height: 100vh;
        border-radius: 0;
        max-width: none;
    }
    
    .chat-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
        padding: 16px 20px;
    }
    
    .header-content h1 {
        font-size: 24px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .chat-input {
        padding: 16px 20px;
    }
    
    .suggestions {
        gap: 8px;
    }
    
    .suggestion-btn {
        min-width: auto;
        width: 100%;
        max-width: 280px;
    }
    
    .input-actions {
        display: none;
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 12px 16px;
    }
    
    .header-content h1 {
        font-size: 20px;
    }
    
    .header-content p {
        font-size: 12px;
    }
    
    .chat-messages {
        padding: 16px;
    }
    
    .chat-input {
        padding: 12px 16px;
    }
    
    #messageInput {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 14px 50px 14px 16px;
    }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(241, 243, 244, 0.5);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(95, 99, 104, 0.3);
    border-radius: 4px;
    transition: background 0.3s ease;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(95, 99, 104, 0.5);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .ai-message {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        color: #e2e8f0;
        border-color: #4a5568;
    }
    
    .suggestion-btn {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        color: #e2e8f0;
        border-color: #4a5568;
    }
}