/* --- BIẾN CSS & CHẾ ĐỘ TỐI --- */
:root {
    --primary-color: #8B4513;
    --primary-hover: #70360f;
    --bg-color: #f4f5f7;
    --card-bg: #ffffff;
    --text-main: #2d2d2d;
    --text-sub: #555555;
    --border-color: #ececec;
    --item-bg: #f9f9f9;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
    --bot-msg-bg: #f0f2f5;
    --user-msg-bg: #8B4513;
}

body.dark-theme {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-main: #e4e6eb;
    --text-sub: #b0b3b8;
    --border-color: #3a3b3c;
    --item-bg: #242526;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    --bot-msg-bg: #3a3b3c;
    --user-msg-bg: #a0522d;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--bg-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    transition: background-color 0.4s ease;
}

/* --- GIAO DIỆN CHÍNH --- */
.card {
    position: relative;
    width: 100%;
    max-width: 460px;
    height: 92vh;
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.4s ease;
}

.header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: var(--card-bg);
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
}

.back-btn {
    background: var(--item-bg);
    border: 1px solid var(--border-color);
    color: var(--primary-color);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 18px;
    transition: all 0.3s;
    margin-right: 15px;
}

.back-btn:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.header-action-btn {
    background: transparent;
    border: none;
    color: var(--text-sub);
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    transition: color 0.3s;
}

.header-action-btn:hover {
    color: #dc3545;
}

.header-info {
    display: flex;
    flex-direction: column;
}

.header-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-main);
}

.header-status {
    font-size: 13px;
    color: #22c55e;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    font-weight: 500;
}

.dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

/* KHU VỰC CHAT */
.chat-box {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: var(--bg-color);
    scroll-behavior: smooth;
}

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

.chat-box::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 5px;
}

.dark-theme .chat-box::-webkit-scrollbar-thumb {
    background: #475569;
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    animation: fadeIn 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.message-wrapper.bot {
    align-self: flex-start;
}

.message-wrapper.user {
    align-self: flex-end;
    align-items: flex-end;
}

.message {
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.55;
    word-wrap: break-word;
}

.message.bot {
    background: var(--bot-msg-bg);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
}

.message.user {
    background: var(--user-msg-bg);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.25);
}

.msg-time {
    font-size: 12px;
    color: var(--text-sub);
    margin-top: 6px;
    margin-left: 6px;
    margin-right: 6px;
    font-weight: 500;
}

.message a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
}

.message a:hover {
    text-decoration: underline;
}

.dark-theme .message.bot a {
    color: #d28c5a;
}

.dark-theme .message.user a {
    color: #fff;
}

.typing-indicator {
    font-size: 13px;
    color: var(--text-sub);
    margin-left: 10px;
    font-style: italic;
    display: none;
    margin-top: -5px;
    margin-bottom: 10px;
    font-weight: 500;
}

/* NÚT GỢI Ý */
.quick-replies {
    display: flex;
    gap: 10px;
    padding: 12px 15px;
    overflow-x: auto;
    background: var(--card-bg);
    white-space: nowrap;
    border-top: 1px solid var(--border-color);
    scrollbar-width: thin; /* Hỗ trợ Firefox */
    scrollbar-color: #cbd5e1 transparent;
}

.quick-replies::-webkit-scrollbar {
    height: 4px;
}
.quick-replies::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

.quick-btn {
    padding: 10px 18px;
    border-radius: 20px;
    border: 1px solid var(--primary-color);
    background: var(--item-bg);
    color: var(--primary-color);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.quick-btn:hover {
    background: var(--primary-color);
    color: #fff;
    transform: translateY(-1px);
}

/* BOX GỢI Ý AUTO-COMPLETE KHI ĐANG GÕ */
.suggestions-box {
    position: absolute;
    bottom: 75px;
    left: 15px;
    right: 15px;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 100;
    border: 1px solid var(--border-color);
    max-height: 220px;
    overflow-y: auto;
}

.suggestion-item {
    padding: 14px 18px;
    font-size: 15px;
    color: var(--text-main);
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.suggestion-item:hover {
    background: var(--item-bg);
    color: var(--primary-color);
    font-weight: 600;
}

/* KHU VỰC NHẬP TEXT */
.input-area {
    padding: 15px 20px;
    background: var(--card-bg);
    display: flex;
    gap: 12px;
    align-items: center;
    position: relative;
}

.chat-input {
    flex: 1;
    padding: 14px 20px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    background: var(--item-bg);
    color: var(--text-main);
    font-size: 15px;
    outline: none;
    transition: 0.3s;
}

.chat-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

.send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: 0.3s;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(139, 69, 19, 0.2);
}

.send-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

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

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}