/* =========================================
   1. SHARED STYLES (Dùng chung)
   ========================================= */
:root {
    --bg-color: #F5F5F7;
    --card-bg: #FFFFFF;
    --primary: #0068ff; /* Zalo Blue */
    --text-primary: #333;
    --text-sec: #888;
    --border-color: #e0e0e0;
    --radius: 12px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

body { 
    background-color: var(--bg-color); 
    color: var(--text-primary); 
    line-height: 1.5;
}

/* Button & Form */
.btn { background: var(--primary); color: white; border: none; padding: 12px 20px; border-radius: 6px; font-weight: 600; cursor: pointer; width: 100%; font-size: 15px; transition: 0.2s; }
.btn:active { opacity: 0.9; transform: scale(0.98); }
.btn-secondary { background: #E5E5EA; color: #333; }
.back-btn { display: none; } /* Mặc định ẩn nút Back trên PC */

input, textarea, select { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; outline: none; background: #fff; }
input:focus, textarea:focus { border-color: var(--primary); }
.form-group { margin-bottom: 15px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--text-primary); }

/* =========================================
   2. CLIENT UI (Giao diện Khách - Glassmorphism)
   ========================================= */
body.client-page {
    background: url('https://images.unsplash.com/photo-1557683316-973673baf926?q=80&w=2029&auto=format&fit=crop') no-repeat center center fixed;
    background-size: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
}

.glass-container {
    width: 100%;
    max-width: 500px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 24px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    padding: 30px;
    color: #fff;
}

.glass-container .card { background: transparent; box-shadow: none; border: none; padding: 0; margin: 0; }
.glass-container input, .glass-container textarea, .glass-container select {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: #000;
    font-weight: 500;
}
.glass-container label { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.glass-container h2 { color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.3); }

.glass-container .tabs { background: rgba(255, 255, 255, 0.3); border-radius: 12px; display: flex; margin-bottom: 20px; padding: 4px; }
.glass-container .tab-btn { flex: 1; padding: 8px; text-align: center; cursor: pointer; color: #eee; font-weight: 600; border-radius: 8px; }
.glass-container .tab-btn.active { background: #fff; color: #0068ff; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }

/* =========================================
   3. ADMIN UI (PC)
   ========================================= */
.admin-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 100vh;
    overflow: hidden;
    background: #fff;
}

.sidebar { border-right: 1px solid var(--border-color); display: flex; flex-direction: column; background: #fff; height: 100vh; }
.sidebar-header { padding: 16px; font-weight: 700; font-size: 18px; border-bottom: 1px solid #f0f0f0; }

.search-filter-row { display: flex; padding: 8px 12px; gap: 8px; border-bottom: 1px solid #f0f0f0; }
.search-filter-row input { background: #f1f1f1; border-radius: 20px; border: none; font-size: 13px; flex: 1; }
.search-filter-row select { width: 90px; border-radius: 20px; font-size: 12px; border: 1px solid #ddd; }

.msg-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.msg-item { display: flex; padding: 12px; cursor: pointer; border-bottom: 1px solid #f5f5f5; align-items: center; gap: 12px; }
.msg-item:hover, .msg-item.active { background: #e8f2ff; }
.avatar { width: 45px; height: 45px; border-radius: 50%; object-fit: cover; border: 1px solid #eee; flex-shrink: 0; }
.msg-info { flex: 1; overflow: hidden; }
.msg-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.msg-preview { font-size: 12px; color: #888; display: flex; justify-content: space-between; }

.main-content { background: #f5f7fa; display: flex; flex-direction: column; height: 100vh; overflow: hidden; position: relative; }
.chat-area { flex: 1; overflow-y: auto; padding: 20px; }
.detail-card { background: #fff; padding: 25px; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,0.1); max-width: 800px; margin: 0 auto; }

/* Modal */
.modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); align-items: center; justify-content: center; }
.modal-content { background-color: #fff; padding: 24px; border-radius: 12px; width: 400px; box-shadow: 0 4px 20px rgba(0,0,0,0.2); animation: popUp 0.3s; }
.modal-title { font-size: 18px; font-weight: bold; margin-bottom: 16px; }
@keyframes popUp { from {transform: scale(0.8); opacity: 0;} to {transform: scale(1); opacity: 1;} }

/* =========================================
   4. ADMIN MOBILE RESPONSIVE (Slide Effect)
   ========================================= */
@media (max-width: 768px) {
    .admin-container { grid-template-columns: 100%; height: 100dvh; }
    
    /* Sidebar chiếm full màn hình */
    .sidebar { width: 100%; border-right: none; display: flex; flex-direction: column; height: 100dvh; }
    .sidebar.hidden-on-mobile { display: none; } /* Class ẩn sidebar */
    
    /* Msg-list cho mobile */
    .msg-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

    /* Main Content ẩn mặc định */
    .main-content {
        display: none; 
        position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
        z-index: 100; background: #fff;
    }
    
    /* Khi mở chi tiết -> Hiện Main Content */
    .main-content.open { 
        display: flex;
        flex-direction: column;
    }

    /* Nút Back hiện lên */
    .back-btn {
        display: inline-block;
        margin-bottom: 15px; padding: 8px 15px;
        background: #f0f0f0; border-radius: 20px;
        font-size: 14px; font-weight: 600; color: #333;
        border: none; cursor: pointer;
    }
    
    /* Ensure chat area takes available space but allows footer to be visible */
    .chat-area {
        display: flex;
        flex-direction: column;
        height: 100%;
        flex: 1;
    }
    
    /* Chat header stays at top */
    .chat-header {
        flex-shrink: 0;
    }
    
    /* Chat container expands but scrolls */
    #chat-messages {
        flex: 1;
        overflow-y: auto;
        height: auto;
    }
    
    /* Chat footer stays at bottom */
    .chat-footer {
        flex-shrink: 0;
        position: relative !important;
        bottom: auto !important;
    }
    
    .detail-card { padding: 15px; border-radius: 0; height: 100%; overflow-y: auto; box-shadow: none; }
    
    /* Cắt chữ để không vỡ layout */
    a, p, span, div { overflow-wrap: break-word; word-wrap: break-word; word-break: break-word; }
    #d_link_href { word-break: break-all; }
}

/* Toast */
#toast { visibility: hidden; min-width: 250px; background-color: #333; color: #fff; text-align: center; border-radius: 8px; padding: 16px; position: fixed; z-index: 3000; left: 50%; bottom: 30px; transform: translateX(-50%); }
#toast.show { visibility: visible; animation: fadein 0.5s; }
@keyframes fadein { from {bottom: 0; opacity: 0;} to {bottom: 30px; opacity: 1;} }
