/* === BẮT ĐẦU CSS MỚI HOÀN CHỈNH === */

/* --- Cài đặt chung, Font & Biến màu --- */
:root {
    --primary-color: #0d6efd; /* Chuyển sang màu xanh dương hiện đại */
    --primary-color-light: #e7f3ff;
    --background-color: #f8f9fa;
    --card-background-color: #ffffff;
    --border-color: #dee2e6;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --hover-overlay: #f0f2f5;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-size: inherit;
    font-family: inherit;
}

/* --- Cấu trúc Layout chính --- */
.app-layout {
    display: flex;
    height: 100vh;
}

/* --- 1. Sidebar (Bên trái) --- */
.sidebar {
    width: 280px;
    flex-shrink: 0; /* <-- THÊM DÒNG NÀY */
    background-color: var(--card-background-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    font-size: 22px;
    font-weight: bold;
    color: var(--primary-color);
    justify-content: center;
}

.logo .fa-comments {
    margin-right: 10px;
}

.logout-btn {
    font-size: 18px;
    color: var(--text-secondary);
    transition: color 0.2s;
}
.logout-btn:hover { color: var(--text-primary); }

.user-info {
    padding: 16px 20px;
    font-weight: 600;
    position: relative;
    padding-bottom: 65px; /* Tăng không gian cho nút bấm */
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.phone-numbers-section {
    flex-grow: 1;
    overflow-y: auto;
    padding: 8px;
}

.phone-numbers-section p {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 12px;
    text-transform: uppercase;
}

.phone-number-item {
    padding: 12px 16px;
    margin: 0 8px 4px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    font-weight: 500;
    display: block;
}

.phone-number-item:hover {
    background-color: var(--hover-overlay);
}

.phone-number-item.active {
    background-color: var(--primary-color-light);
    color: var(--primary-color);
    font-weight: 600;
}

/* --- 2. Conversations Panel (Ở giữa) --- */
.conversations-panel {
    width: 360px;
    flex-shrink: 0; /* <-- THÊM DÒNG NÀY */
    border-right: 1px solid var(--border-color);
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
}

.conversations-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.conversations-header h2 { font-size: 20px; font-weight: 600; }

.new-message-btn-main {
    background-color: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    transition: background-color 0.2s;
}
.new-message-btn-main:hover { background-color: #0b5ed7; }
.new-message-btn-main .fa-pen-to-square { margin-right: 8px; }

.search-bar {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.search-bar input {
    width: 100%;
    padding: 10px 16px;
    border-radius: 20px;
    border: none;
    background-color: var(--hover-overlay);
    outline: none;
}

#conversations-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 8px;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin: 0 4px 4px 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.conversation-item:hover {
    background-color: var(--hover-overlay);
}
.conversation-item.active {
    background-color: #e9ecef;
}

.convo-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #e4e6eb;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 20px;
    color: var(--text-primary);
    flex-shrink: 0;
}

.convo-details {
    overflow: hidden;
}
.convo-number {
    font-weight: 600;
}
.convo-preview {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 5px;
}
.empty-list { text-align: center; color: var(--text-secondary); margin-top: 20px; padding: 0 16px; }


/* --- 3. Chat Panel (Bên phải) --- */
.chat-panel {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* <--- THÊM DÒNG NÀY */
}

.welcome-screen {
    flex-grow: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-secondary);
}
.welcome-screen .fa-comments {
    font-size: 60px;
    color: #ced4da;
    margin-bottom: 20px;
}
.welcome-screen h2 {
    font-size: 22px;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.chat-window {
    display: flex;
    flex-direction: column;
    flex: 1; /* <-- THAY ĐỔI QUAN TRỌNG */
    min-height: 0; /* <-- THÊM DÒNG NÀY */
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background-color: #ffffff;
    font-size: 18px;
    font-weight: 600;
    flex-shrink: 0;
}

.messages-container {
    flex-grow: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message-bubble {
    max-width: 65%;
    padding: 10px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
}

.message-bubble.sent {
    background-color: var(--primary-color);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message-bubble.received {
    background-color: #e4e6eb;
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message-bubble.image-only {
    padding: 4px;
    background-color: transparent;
}

.message-bubble.image-only img {
    display: block;
    max-width: 300px;
    height: auto;
    object-fit: cover;
    border-radius: 15px;
}

#send-message-form, #send-new-message-form {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    border-top: 1px solid var(--border-color);
    background-color: #ffffff;
    flex-shrink: 0;
}

#message-input, #new-message-input, #new-recipient-input {
    flex-grow: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 22px;
    background-color: var(--hover-overlay);
    outline: none;
    font-size: 15px;
}

.attach-btn, #send-message-form button[type="submit"], #send-new-message-form button[type="submit"] {
    font-size: 22px;
    color: var(--text-secondary);
    transition: color 0.2s;
    flex-shrink: 0;
}

#send-message-form button[type="submit"], #send-new-message-form button[type="submit"] {
    color: var(--primary-color);
}

.attach-btn:hover, #send-message-form button[type="submit"]:hover, #send-new-message-form button[type="submit"]:hover {
    color: var(--text-primary);
}

.new-message-recipient {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}
.new-message-recipient span {
    font-weight: 600;
}

/* --- Các style cũ cho chức năng đặc biệt --- */
.conversation-item .convo-details {
    position: relative;
    width: 100%;
}
.phone-number-item {
    position: relative;
}
#repay-numbers-btn {
    position: absolute;
    bottom: 12px; left: 20px; right: 20px;
    width: calc(100% - 40px); padding: 10px;
    background-color: #ffc107; color: #212529;
    border-radius: 8px; font-weight: 600; font-size: 14px;
    transition: background-color 0.2s, transform 0.1s;
}
#repay-numbers-btn:hover { background-color: #ffca2c; }
#repay-numbers-btn:active { transform: scale(0.98); }
#repay-numbers-btn:disabled {
    background-color: #6c757d; cursor: not-allowed; color: white;
}
/* --- CSS CHO TRANG ĐĂNG NHẬP --- */
body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.card {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 32px;
}

.login-card {
    max-width: 400px;
    width: 90%;
}

.login-card h2 {
    text-align: center;
    font-size: 24px;
    margin-bottom: 24px;
    color: #1c1e21;
}

.login-card form input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.login-card form input:focus {
    border-color: var(--primary-color);
}

.login-card form button {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.login-card form button:hover {
    background-color: #0b5ed7;
}
/* === BẮT ĐẦU CSS CHO GIAO DIỆN LOGIN GỐC === */

/* --- Cài đặt chung cho trang login gốc --- */
/* --- Cài đặt chung cho trang login gốc --- */
html, body.login-page-original { /* <--- THÊM 'html,' VÀO ĐÂY */
    font-family: 'Roboto', sans-serif;
    background-color: #f8f9fa;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
    /* Ghi đè style toàn cục, cho phép cuộn trên cả html và body */
    overflow: auto !important; 
    height: auto !important;
}

/* Thẻ card chính */
.login-card-original {
    background-color: #ffffff;
    padding: 40px 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    width: 100%;
    text-align: center;
}

/* Logo */


.login-card-original h2 {
    margin: 0 0 10px;
    font-size: 24px;
    color: #333;
    font-weight: 700;
}

.sub-heading {
    margin: 0 0 30px;
    font-size: 14px;
    color: #666;
}
.sub-heading a {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
}
.sub-heading a:hover {
    text-decoration: underline;
}

/* Input */
.login-form-original .input-group {
    position: relative;
    margin-bottom: 20px;
}
.login-form-original .input-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 16px;
    box-sizing: border-box;
    padding-top: 20px;
}
.login-form-original .input-group label {
    position: absolute;
    top: 5px;
    left: 12px;
    font-size: 12px;
    color: #999;
    pointer-events: none;
}

/* Tùy chọn remember/forgot */
.login-form-original .options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    font-size: 14px;
}
.login-form-original .options .remember-me {
    display: flex;
    align-items: center;
    color: #555;
}
.login-form-original .options .remember-me input {
    margin-right: 5px;
}
.login-form-original .options a {
    color: #007bff;
    text-decoration: none;
}
.login-form-original .options a:hover {
    text-decoration: underline;
}

/* Nút bấm chung */
.login-form-original .btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-bottom: 15px;
}

/* Nút Login chính */
.login-form-original .btn-login {
    background-color: #6a0dad;
    color: white;
    text-transform: uppercase;
    font-weight: 700;
}
.login-form-original .btn-login:hover {
    background-color: #5a0ca0;
}

/* Dấu ngăn cách */
.login-form-original .separator {
    display: flex;
    align-items: center;
    text-align: center;
    color: #aaa;
    margin-bottom: 15px;
}
.login-form-original .separator::before, .login-form-original .separator::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #eee;
}
.login-form-original .separator span {
    padding: 0 10px;
}

/* Nút social */
.login-form-original .btn-social {
    background-color: #fff;
    color: #555;
    border: 1px solid #ddd;
}
.login-form-original .btn-social:hover {
    background-color: #f7f7f7;
}
.login-form-original .btn-facebook {
    background-color: #1877F2;
    color: white;
    border: none;
}
.login-form-original .btn-facebook:hover {
    background-color: #166fe5;
}

/* Link chân trang */
.footer-help {
    margin: 20px 0;
    font-size: 14px;
}
.footer-help a {
    color: #007bff;
    text-decoration: none;
}
.footer-links {
    font-size: 12px;
    color: #888;
}
.footer-links a {
    color: inherit;
    text-decoration: none;
    margin: 0 5px;
}
.footer-links a:hover {
    text-decoration: underline;
}
/* --- CSS CHO LOGO CHATRIO TRÊN TRANG LOGIN --- */
.chatrio-logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 25px; /* Khoảng cách với tiêu đề "Welcome back" */
    gap: 10px; /* Khoảng cách giữa icon và chữ */
}

.chatrio-logo-container svg {
    /* Màu của icon bong bóng thoại, giống như trong hình */
    fill: #007bff; /* Màu xanh dương */
    width: 40px; /* Kích thước icon */
    height: 40px;
}

.chatrio-text {
    font-size: 32px; /* Kích thước chữ "Chatrio" */
    font-weight: 700; /* Độ đậm của chữ */
    color: #007bff; /* Màu chữ "Chatrio", giống như trong hình */
    letter-spacing: -0.5px; /* Điều chỉnh khoảng cách chữ một chút */
}
/* === KẾT THÚC CSS CHO GIAO DIỆN LOGIN GỐC === */
/* === KẾT THÚC CSS MỚI === */