:root {
    --primary-red: #8a1529;
    --primary-red-hover: #a31b32;
    --dark-bg: #121212;
    --card-bg: #1e1e1e;
    --text-color: #e0e0e0;
    --accent-gold: #c5a059;
    --glass-bg: rgba(30, 30, 30, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* FIX: Ngăn toàn bộ trang bị scroll, ép chiều cao khớp màn hình mobile */
html, body {
    height: 100%;
    height: 100svh; /* Đơn vị mới giúp khớp chính xác màn hình mobile */
    overflow: hidden;
}

body {
    background-color: var(--dark-bg);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    background: linear-gradient(-45deg, #1e0508, #121212, #0d0203, #000000);
    background-size: 400% 400%;
    animation: gradientBG 20s ease infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 2rem;
    background: linear-gradient(to bottom, rgba(230, 230, 230, 0.95), rgba(210, 210, 210, 0.9));
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    flex-shrink: 0; /* Không cho phép header bị co lại */
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.header-tagline {
    color: #333;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    flex: 2;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex: 1;
    justify-content: flex-end;
}

.logo-container img {
    height: 60px;
    width: auto;
    transition: transform 0.4s;
}

.return-btn {
    text-decoration: none;
    color: #ffffff;
    background: #000000;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.header-btn {
    padding: 8px 15px;
    background: var(--primary-red);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
}

/* FIX: Main chiếm trọn diện tích còn lại */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    overflow: hidden; /* Quan trọng để con không tràn ra */
    padding: 10px;
}

/* FIX: Chat container co giãn theo Main */
.chat-container {
    background: var(--glass-bg);
    width: 100%;
    height: 100%;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

/* FIX: Chat history tự scroll bên trong */
#chat-history {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    -webkit-overflow-scrolling: touch; /* Scroll mượt trên iOS */
}

.message {
    max-width: 85%;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 1rem;
    white-space: pre-wrap;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-message {
    align-self: flex-end;
    background: var(--primary-red);
    color: white;
    border-bottom-right-radius: 4px;
}

.assistant-message {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 4px;
}

.typing-indicator {
    padding: 0.5rem 1.5rem;
    display: none;
    gap: 5px;
}

.dot {
    width: 6px; height: 6px;
    background: var(--accent-gold);
    border-radius: 50%;
    animation: bounce 0.6s infinite alternate;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-5px); }
}

.input-area {
    padding: 1rem 1.5rem;
    background: rgba(0, 0, 0, 0.4);
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 0.75rem; /* Giảm gap một chút */
    flex-shrink: 0;
    width: 100%; /* Đảm bảo không vượt quá container cha */
    align-items: center;
}

input[type="text"] {
    flex: 1;
    min-width: 0; /* QUAN TRỌNG: Cho phép input co lại nhỏ hơn nội dung của nó */
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 16px; 
    outline: none;
}

button#send-btn {
    flex-shrink: 0; /* Ngăn nút Send bị bóp méo hoặc biến mất */
    background: var(--primary-red);
    color: white;
    border: none;
    height: 40px; /* Cố định chiều cao để cân đối */
    padding: 0 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap; /* Không cho chữ Send xuống dòng */
}
/* --- MOBILE OPTIMIZATION --- */
@media (max-width: 768px) {
    header {
        padding: 8px 12px;
        flex-wrap: wrap;
    }

    .logo-container img { height: 45px; }

    .header-tagline { display: none; }

    .header-actions {
        flex: 1 0 100%;
        margin-top: 8px;
        justify-content: space-between;
    }

    .header-btn {
        flex: 1;
        text-align: center;
        font-size: 0.75rem;
        padding: 6px;
    }

    main {
        padding: 5px;
    }

    .chat-container {
        border-radius: 12px;
    }

    .input-area {
        padding: 10px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
	.logo-group {
    display: flex;
    align-items: center;
    /* gap: 15px; */
    flex: 1;
    justify-content: space-between;
}
	.modal-body {
		font-size: 0.8rem;
}

}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.modal-overlay.active { display: flex; }

.modal-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    max-width: 90%;
    position: relative;
    border: 1px solid var(--glass-border);
}

.modal-close {
    position: absolute;
    top: 10px; right: 15px;
    background: none; border: none;
    color: white; font-size: 1.5rem;
    cursor: pointer;
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}