:root {
    --primary-color: #0088cc;
    --primary-hover: #006699;
    --bg-color: #f0f2f5;
    --sidebar-bg: #ffffff;
    --chat-bg: #e5ddd5;
    --text-color: #333333;
    --text-muted: #888888;
    --border-color: #e0e0e0;
    --msg-in-bg: #ffffff;
    --msg-out-bg: #dcf8c6;
    --header-bg: #ffffff;
    --danger-color: #ff3b30;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #2b5278;
        --primary-hover: #3b6b9e;
        --bg-color: #0e1621;
        --sidebar-bg: #17212b;
        --chat-bg: #0e1621;
        --text-color: #f5f5f5;
        --text-muted: #7f91a4;
        --border-color: #101921;
        --msg-in-bg: #182533;
        --msg-out-bg: #2b5278;
        --header-bg: #17212b;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html, body {
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    height: 100dvh;
}

/* LOGIN */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
   
}

.login-container {
    background: var(--sidebar-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-header i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.input-icon {
    position: relative;
}

.input-icon i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-icon input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
}

.input-icon input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 136, 204, 0.1);
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.3s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-block {
    width: 100%;
}

.login-footer {
    margin-top: 1.5rem;
    color: var(--text-muted);
}

.login-footer a {
    color: var(--primary-color);
    text-decoration: none;
}

.alert {
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
}

.alert-danger {
    background-color: rgba(255, 59, 48, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(255, 59, 48, 0.2);
}

/* APP LAYOUT */
.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow-x: hidden;
}

.sidebar {
    width: 350px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    overflow-x: hidden;
    min-height: 0;
}

/* SIDEBAR HEADER */
.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--header-bg);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.header-actions .btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.header-actions .btn-icon:hover {
    background: rgba(0,0,0,0.05);
    color: var(--text-color);
}

.search-bar {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

.search-bar input {
    width: 100%;
    padding: 12px 15px;
    font-size: 1.1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    outline: none;
}

/* CONVERSATION LIST */
.conversation-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    padding: 12px 15px;
    gap: 15px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.conversation-item:hover, .conversation-item.active {
    background: rgba(0, 136, 204, 0.1);
}

.conv-avatar {
    position: relative;
}

.conv-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

.conv-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 5px;
}

.conv-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.conv-last-msg {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* CHAT AREA */
.chat-header {
    padding: 15px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-actions .btn-icon {
    background: transparent;
    border: none;
    color: var(--text-color); /* Màu chữ đen trắng/tiêu chuẩn, không lòe loẹt */
    font-size: 1.1rem; /* Thu nhỏ 2/3 so với 1.6rem cũ */
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.chat-actions .btn-icon:hover {
    background: rgba(0,0,0,0.05);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

.message {
    max-width: 70%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.message.in {
    align-self: flex-start;
}

.message.out {
    align-self: flex-end;
}

.message-bubble {
    padding: 10px 15px;
    border-radius: 12px;
    font-size: 0.95rem;
    position: relative;
    z-index: 20;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.message.in .message-bubble {
    background: var(--msg-in-bg);
    border-bottom-left-radius: 2px;
}

.message.out .message-bubble {
    background: var(--msg-out-bg);
    border-bottom-right-radius: 2px;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    align-self: flex-end;
    margin-top: 5px;
}

.message-actions {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    gap: 5px;
    background: var(--sidebar-bg);
    padding: 5px;
    border-radius: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 10;
}

/* Tạo cầu nối vô hình để chuột không bị mất hover khi di chuyển qua khoảng trống */
.message-actions::before {
    content: '';
    position: absolute;
    top: -20px;
    bottom: -20px;
    left: -40px;
    right: -40px;
    z-index: -1;
}

.message.in .message-actions {
    right: -80px;
}

.message.out .message-actions {
    left: -80px;
}

.message:hover .message-actions {
    display: flex;
}

.message-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
}

.message-actions button:hover {
    color: var(--primary-color);
}

.message-actions .btn-danger:hover {
    color: var(--danger-color);
}

/* CHAT INPUT */
.chat-input {
    padding: 12px 15px;
    background: var(--header-bg);
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
    border-top: 1px solid var(--border-color);
    width: 100%;
    box-sizing: border-box;
}

.chat-input .btn-icon {
    font-size: 1.2rem;
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    box-sizing: border-box;
}

.chat-input .btn-icon i {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.chat-input .btn-icon:hover {
    background: rgba(0,0,0,0.05);
    color: var(--primary-color);
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: absolute;
        z-index: 10;
        height: 100%;
    }
    .sidebar.hidden {
        display: none !important;
    }
    .main-chat {
        width: 100%;
    }
    .btn-back {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 10px;
        width: 30px;
        height: 60px;
        font-size: 2.2rem;
        padding: 15px;
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.modal-content {
    background: var(--sidebar-bg);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    overflow: hidden;
    animation: slideDown 0.3s ease;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--primary-color);
    color: #fff;
}
.modal-header h2 { margin: 0; font-size: 1.2rem; }
.close-btn { background: transparent; border: none; color: #fff; font-size: 1.2rem; cursor: pointer; }
.modal-body { padding: 20px; }

/* Switch Toggle */
.switch { position: relative; display: inline-block; width: 40px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 2px; bottom: 2px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(20px); }

@media (max-width: 768px) { .chat-header { padding: 5px 10px; flex-wrap: wrap; } .chat-header-info { gap: 10px; } .chat-header .avatar { width: 30px; height: 30px; font-size: 14px; } .chat-header h3 { font-size: 1rem; margin: 0; } .chat-header small { font-size: 0.75rem; } }

@media (max-width: 768px) {
    .search-bar input {
        padding: 12px 15px;
        font-size: 1.1rem;
    }
    #btnUnlockHidden {
        font-size: 1.3rem;
        pa/* ADMIN CHAT LAYOUT */
.admin-chat-layout {
    display: flex;
    gap: 20px;
    flex-direction: row;
}

.admin-chat-list-container {
    flex: 1;
    overflow-y: visible;
    background: var(--header-bg);
    border-radius: 8px;
}

.admin-chat-messages-container {
    flex: 2;
    background: var(--header-bg);
    border-radius: 8px;
    padding: 15px;
    overflow-y: visible;
}

@media (max-width: 768px) {
    .admin-chat-layout {
        flex-direction: column;
    }
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 768px) {
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr { margin-bottom: 15px; border: 1px solid var(--border-color); border-radius: 8px; padding: 10px; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
    .data-table td { text-align: right; padding-left: 45%; position: relative; border-bottom: 1px solid #eee; min-height: 40px; display: flex; align-items: center; justify-content: flex-end; }
    .data-table td:last-child { border-bottom: 0; }
    .data-table td::before { content: attr(data-label); position: absolute; left: 10px; width: 40%; text-align: left; font-weight: bold; color: var(--text-color); }
}

.input-wrapper {
    flex: 1 1 0%;
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    background: var(--bg-color);
    border-radius: 25px;
    padding: 2px 12px;
    border: 1px solid var(--border-color);
    min-width: 0;
    box-sizing: border-box;
    height: 44px;
}

.input-wrapper input {
    flex: 1 1 0%;
    border: none;
    background: transparent;
    color: var(--text-color);
    outline: none;
    font-size: 1rem;
    padding: 0 8px;
    margin: 0;
    min-width: 0;
    height: 100%;
    box-sizing: border-box;
}

.input-wrapper .btn-icon {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
}

.btn-send {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
    box-shadow: 0 4px 10px rgba(0, 136, 204, 0.3);
    flex-shrink: 0;
}

.btn-send i {
    font-size: 2rem;
    margin-left: -4px; /* Căn chỉnh nhẹ icon máy bay cho vào giữa */
}

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

/* ADMIN PANEL OVERRIDES */
.admin-container {
    padding: 20px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
    overflow-y: visible;
}

@media (max-width: 768px) {
    .admin-container {
        padding: 10px;
    }
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--sidebar-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.table th, .table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background: rgba(0,0,0,0.02);
    font-weight: 600;
}

.table tr:hover {
    background: rgba(0,0,0,0.02);
}

.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
}

