/* ==========================================================================
   1. CẤU HÌNH GIAO DIỆN & HÌNH NỀN (WORKHUB AI THEME)
   ========================================================================== */
:root {
  --main-bg-image: none;

  /* --- MÀU SẮC --- */
  --primary-color: #0f62fe;       /* Xanh dương IBM (Nổi bật trên nền sáng) */
  --primary-hover: #0043ce;       
  --accent-light: #e8f0fe;        
  
  --bg-body: #f4f6f8;             /* Màu nền lót phòng khi ảnh chưa tải */
  
  
  --text-primary: #1f2937;        /* Chữ đen than (Đậm đà) */
  --text-secondary: #4b5563;      /* Chữ xám đậm */
  
  --success-color: #059669;       
  --danger-color: #dc2626;        
  --warning-color: #d97706;       

  /* --- KÍCH THƯỚC --- */
  --font-base: 15px;
  --header-height: 64px;
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --border-radius: 12px;
  
  /* --- HIỆU ỨNG --- */
  --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.05); 
  --shadow-md: 0 10px 15px rgba(0, 0, 0, 0.1); /* Bóng đổ mềm mại */
  --transition: all 0.25s ease-in-out;
}

/* ==========================================================================
   2. GLOBAL STYLES (CẤU HÌNH BODY)
   ========================================================================== */
* { box-sizing: border-box; outline: none; }

body {
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  margin: 0; padding: 0;
  
  /* CẤU HÌNH HÌNH NỀN */
  background-image: var(--main-bg-image);
  background-color: var(--bg-body);
  background-size: cover;           /* Phủ kín toàn màn hình */
  background-position: center;      /* Căn giữa ảnh */
  background-attachment: fixed;     /* Cố định ảnh khi cuộn chuột */
  background-repeat: no-repeat;
  
  color: var(--text-primary);
  font-size: var(--font-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    color: #111827; 
    font-weight: 700;
    text-shadow: 0 2px 0 rgba(255,255,255,0.8); 
}

#main-container, 
#main-content {
    background: transparent !important; /* Trong suốt hoàn toàn */
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}


/* ==========================================================================
   3. LAYOUT (HEADER & SIDEBARS)
   ========================================================================== */

/* --- 3.1 Header --- */
#app-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 24px;
  background-color: var(--bg-surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  height: var(--header-height);
  position: sticky; top: 0; z-index: 100;
}

.logo { font-size: 26px; font-weight: 800; color: var(--primary-color); letter-spacing: -0.5px; }

.user-info { display: flex; align-items: center; gap: 20px; }

#user-display {
  cursor: pointer; font-weight: 500; display: flex; align-items: center;
  gap: 8px; padding: 5px 10px; border-radius: 20px; transition: var(--transition);
}
#user-display:hover { background-color: #f1f3f4; }
#user-display i { font-size: 22px; color: var(--primary-color); }

/* --- 3.2 Main Container --- */
#main-container {
  display: flex;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

#main-content {
  flex-grow: 1; padding: 30px 40px; overflow-y: auto; background-color: var(--bg-body);
}

.content-section h2 {
  font-size: 24px; font-weight: 500; color: var(--text-primary);
  margin-bottom: 30px; border-bottom: 2px solid #e0e0e0; padding-bottom: 15px;
}

/* --- 3.3 Left Sidebar (Menu) --- */
#app-sidebar {
  width: var(--sidebar-collapsed);
  background-color: var(--bg-surface);
  border-right: 1px solid #e0e0e0;
  padding-top: 15px; flex-shrink: 0; height: 100%;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; flex-direction: column; overflow-x: hidden;
}
#app-sidebar.expanded { width: var(--sidebar-width); }
#app-sidebar ul { list-style: none; padding: 0 12px; margin: 0; }

.nav-item {
  display: flex; align-items: center; padding: 14px 16px; margin-bottom: 6px;
  cursor: pointer; border-radius: var(--border-radius);
  color: var(--text-secondary); font-weight: 500; transition: var(--transition);
  justify-content: center; white-space: nowrap;
}
.nav-item:hover { background-color: #f1f3f4; color: var(--primary-color); transform: translateX(3px); }
.nav-item.active { background-color: var(--accent-light); color: var(--primary-color); font-weight: 700; }
.nav-item i { font-size: 22px; min-width: 26px; text-align: center; }

#app-sidebar.expanded .nav-item { justify-content: flex-start; }
#app-sidebar.expanded .nav-item span { display: inline-block; margin-left: 15px; }
#app-sidebar:not(.expanded) .nav-item span { display: none; }

#hamburger-menu {
  text-align: center; padding: 10px; margin-bottom: 10px; cursor: pointer;
  font-size: 22px; color: var(--text-secondary); transition: color 0.2s;
}
#hamburger-menu:hover { color: var(--primary-color); }

/* --- 3.4 Right Sidebar (Floating Panel - Thành viên) --- */
#right-sidebar {
    position: fixed; top: 20px; bottom: 20px; right: 20px;
    width: 300px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
    border-radius: 20px;
    padding: 20px; z-index: 1050;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex; flex-direction: column;
    border: 1px solid rgba(0,0,0,0.05);
}
#right-sidebar.open { transform: translateX(0); }

.sidebar-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px dashed #eee;
}
.sidebar-header h4 { margin: 0; font-size: 1.1rem; font-weight: 700; color: #333; }

#close-right-sidebar {
    background: none; border: none; font-size: 1.2rem; color: #999;
    cursor: pointer; transition: 0.2s;
}
#close-right-sidebar:hover { color: var(--danger-color); transform: rotate(90deg); }

#member-list-container { flex: 1; overflow-y: auto; padding-right: 5px; }
#member-list-container::-webkit-scrollbar { width: 5px; }
#member-list-container::-webkit-scrollbar-thumb { background: #ccc; border-radius: 10px; }

.member-card {
    display: flex; align-items: center; padding: 10px; margin-bottom: 12px;
    background: #fff; border-radius: 12px; transition: all 0.2s ease;
    border: 1px solid transparent;
    flex-shrink: 0;
}
.member-card:hover {
    background: #f8f9fa; transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05); border-color: #e9ecef;
}

.member-card .member-avatar {
    margin-right: 15px !important; /* Cách xa tên ra (ghi đè cái -10px ở trên) */
    margin-left: 0 !important;     /* Reset lề trái */
    width: 45px !important;        /* To hơn cho dễ nhìn */
    height: 45px !important;       /* To hơn cho dễ nhìn */
    font-size: 16px !important;    /* Chữ to hơn */
    flex-shrink: 0;                /* QUAN TRỌNG: Chống bị bóp méo hình */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* Thêm bóng đổ cho đẹp */
    z-index: auto;                 /* Bỏ xếp lớp */
}

/* Thêm hiệu ứng ảnh bên trong (nếu avatar là ảnh img) */
.member-card .member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.status-indicator {
    position: absolute; bottom: 2px; right: 0; width: 12px; height: 12px;
    border-radius: 50%; border: 2px solid #fff;
}
.status-online { background-color: #2ecc71; box-shadow: 0 0 5px #2ecc71; }
.status-offline { background-color: #95a5a6; }

.member-info { display: flex; flex-direction: column; overflow: hidden; min-width: 0; overflow: hidden;}
.member-name { font-weight: 600; font-size: 0.95rem; color: #2c3e50; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-status-text { font-size: 0.75rem; color: #7f8c8d; }
.text-online { color: #2ecc71; font-weight: 500; }

/* ==========================================================================
   4. COMPONENTS (CHUNG)
   ========================================================================== */

/* --- Cards --- */
.card {
  background-color: var(--bg-surface); border-radius: var(--border-radius);
  padding: 25px; margin-bottom: 25px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12); border: 1px solid #f0f0f0;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}
.card:hover { box-shadow: 0 8px 16px rgba(0,0,0,0.1); transform: translateY(-2px); }
.card h3 {
  margin-top: 0; font-size: 1.25rem; font-weight: 600; color: var(--primary-color);
  border-bottom: 1px solid #eee; padding-bottom: 12px; margin-bottom: 20px;
}

/* --- Buttons --- */
button { font-family: inherit; font-size: 15px; letter-spacing: 0.3px; }

.primary-btn, .secondary-btn, #logout-btn {
  border: none; border-radius: 8px; padding: 12px 24px;
  cursor: pointer; font-weight: 600; display: inline-flex;
  align-items: center; justify-content: center; gap: 10px;
  transition: all 0.2s ease; box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.primary-btn { background-color: var(--primary-color); color: white; }
.primary-btn:hover:not(:disabled) { 
  background-color: var(--primary-hover); 
  box-shadow: 0 4px 8px rgba(26, 115, 232, 0.3); transform: translateY(-1px);
}

.secondary-btn { background-color: #fff; color: var(--text-primary); border: 1px solid #dadce0; }
.secondary-btn:hover:not(:disabled) { 
  background-color: #f8f9fa; border-color: #c0c0c0; color: var(--primary-color);
}
button:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; transform: none; }

#logout-btn { background-color: var(--danger-color); color: white; padding: 8px 20px; font-size: 14px; }
#logout-btn:hover { background-color: #b31412; box-shadow: 0 2px 5px rgba(217,48,37,0.3); }

/* --- Inputs & Forms --- */
.form-group { margin-bottom: 20px; }
label { font-weight: 600; margin-bottom: 8px; display: block; color: var(--text-secondary); }

.text-input, textarea, select, input {
  width: 100%; padding: 12px 15px; border: 1px solid #dadce0;
  border-radius: 8px; font-size: 16px; background-color: #fff;
  transition: border 0.2s, box-shadow 0.2s;
}
.text-input:focus, textarea:focus, select:focus, input:focus {
  border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}
textarea { resize: vertical; min-height: 100px; }

.file-upload-label {
  padding: 30px; border: 2px dashed #bdc1c6; border-radius: 12px;
  text-align: center; cursor: pointer; background-color: #f8f9fa;
  color: var(--text-secondary); transition: all 0.2s;
}
.file-upload-label:hover {
  border-color: var(--primary-color); background-color: var(--accent-light);
  color: var(--primary-color);
}

/* --- Tables --- */
.data-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 15px; margin-top: 10px;
}
.data-table th {
  background-color: #f1f3f4; color: var(--text-primary); font-weight: 700;
  padding: 16px; text-align: left; border-bottom: 2px solid #ddd;
  text-transform: uppercase; font-size: 13px; letter-spacing: 0.5px;
}
.data-table td {
  padding: 16px; border-bottom: 1px solid #eee; vertical-align: middle;
  color: var(--text-primary); transition: background-color 0.2s ease;
}
.data-table tbody tr { transition: all 0.2s ease-in-out; }
.data-table tbody tr:hover {
  background-color: var(--accent-light); transform: scale(1.002);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08); z-index: 1; position: relative; cursor: pointer;
}
.data-table td a { color: var(--text-primary); text-decoration: none; font-weight: 500; }
.data-table td a:hover { color: var(--primary-color); text-decoration: underline; }

.action-view { color: var(--primary-color); transition: transform 0.2s; }
.action-delete { color: var(--text-secondary); transition: color 0.2s, transform 0.2s; }
.action-view:hover { transform: scale(1.2); }
.action-delete:hover { color: var(--danger-color); transform: scale(1.2); }

/* ==========================================================================
   5. MODULE: DASHBOARD & PROGRESS
   ========================================================================== */
.main-widgets > div, 
.side-widgets > div {
    background-color: transparent !important; /* Quan trọng: Không tô màu khung bao */
    box-shadow: none !important;
    border: none !important;
}

.dashboard-widgets .card,
.dashboard-widgets .widget-item { 
    /* CHẾ ĐỘ SÁNG */
    background-color: #ffffff !important; 
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05) !important;
    margin-bottom: 20px; /* Tạo khoảng cách giữa các thẻ để nhìn xuyên thấu nền */
    border: 1px solid #eee;
    height: auto !important; /* Quan trọng: Co giãn theo nội dung, không bị kéo dài */
}

.dashboard-widgets {
    display: flex !important;        /* Bắt buộc dùng Flexbox */
    flex-direction: row !important;  /* Bắt buộc xếp ngang */
    align-items: flex-start !important; /* Căn thẳng hàng trên cùng */
    gap: 20px;                       /* Khoảng cách giữa 2 cột */
    flex-wrap: wrap;                 /* Cho phép xuống dòng nếu màn hình quá bé */
}

/* 2. Cột Trái (Nội dung chính - Chiếm phần lớn) */
.main-widgets {
    flex: 1 1 65% !important;        /* Co giãn linh hoạt, chiếm khoảng 65% */
    min-width: 500px;                /* Đừng nhỏ hơn mức này để tránh vỡ giao diện */
    max-width: 100%;                 
}

/* 3. Cột Phải (Sidebar - Chiếm phần nhỏ) */
.side-widgets {
    flex: 1 1 30% !important;        /* Co giãn linh hoạt, chiếm khoảng 30% */
    min-width: 300px;                /* Đảm bảo đủ rộng để hiển thị Widget File */
    max-width: 100%;
}

/* 4. RESPONSIVE: Khi màn hình nhỏ (Tablet/Mobile) thì mới xếp dọc */
@media (max-width: 992px) {
    .dashboard-widgets {
        flex-direction: column !important; /* Xếp dọc lại */
    }
    .main-widgets, 
    .side-widgets {
        width: 100% !important;      /* Full màn hình */
        min-width: 0 !important;     /* Bỏ giới hạn min-width */
        flex: none !important;
    }
}


.progress-bar-bg {
  background: #e0e0e0; border-radius: 12px; height: 26px;
  width: 100%; overflow: hidden; position: relative;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}
.progress-bar-fill {
  background: linear-gradient(90deg, #4285f4, #34a853);
  height: 100%; line-height: 26px; color: white;
  text-align: center; font-size: 13px; font-weight: 700;
  text-shadow: 0 1px 1px rgba(0,0,0,0.2);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   6. MODULE: CALENDAR 2.0 (NEW UI)
   ========================================================================== */
.calendar-container {
    background: #ffffff; padding: 10px; border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05); border: 1px solid #eee; max-width: 100%;
}
.calendar-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; padding-bottom: 10px; border-bottom: 1px solid #f0f0f0;
}
.calendar-header h2 {
    font-size: 1.0rem; font-weight: 700; color: #2c3e50; margin: 0; text-transform: capitalize;
}
.btn-nav-month {
    background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 6px;
    width: 30px; height: 30px; display: flex; align-items: center;
    justify-content: center; cursor: pointer; transition: all 0.2s ease; color: #555;
}
.btn-nav-month:hover { background: #e9ecef; color: #0d6efd; transform: scale(1.05); }

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-day-name {
    text-align: center; font-weight: 600; color: #888; font-size: 0.9rem;
    padding-bottom: 10px; text-transform: uppercase;
}

.calendar-day {
    height: 80px; background: #ffffff; border: 1px solid #f0f0f0;
    border-radius: 10px; display: flex; flex-direction: column;
    align-items: center; justify-content: flex-start; cursor: pointer;
    transition: all 0.2s ease; position: relative; font-weight: 500; color: #333;
}
.calendar-day:hover {
    background-color: #f1f8ff; border-color: #cce5ff;
    transform: translateY(-2px); box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.calendar-day.other-month { background-color: #fafafa; color: #ccc; pointer-events: none; }
.calendar-day.today { border: 2px solid #0d6efd; color: #0d6efd; font-weight: 700; }
.calendar-day.selected {
    background-color: #0d6efd !important; color: #ffffff !important;
    border-color: #0d6efd; box-shadow: 0 4px 10px rgba(13, 110, 253, 0.3);
}

.event-dot {
    width: 6px; height: 6px; background-color: #dc3545; border-radius: 50%;
    margin-top: 6px; opacity: 0; transform: scale(0);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.calendar-day.has-event .event-dot { opacity: 1; transform: scale(1); }
.calendar-day.selected .event-dot { background-color: #ffffff; }

/* Calendar Sidebar List */
.today-events-widget { min-height: 400px; background: #fff; border-radius: 12px; }
.today-events-widget h3 {
    font-size: 1.1rem; font-weight: 700; color: #333;
    border-bottom: 2px solid #f0f0f0; padding-bottom: 10px; margin-bottom: 15px;
}

.event-item {
    background: #ffffff; border: 1px solid #eee; border-left: 4px solid #0d6efd;
    padding: 12px; margin-bottom: 10px; border-radius: 6px; position: relative;
    transition: all 0.2s; cursor: pointer;
}
.event-item:hover {
    transform: translateX(4px); box-shadow: 0 2px 8px rgba(0,0,0,0.08); border-color: #ddd;
}
.event-item.important { border-left-color: #dc3545; background-color: #fff8f8; }

.event-time { font-size: 0.85rem; font-weight: 700; color: #555; margin-bottom: 4px; }
.event-title { font-size: 1rem; font-weight: 600; color: #222; line-height: 1.4; margin-bottom: 6px; }
.event-meta { font-size: 0.8rem; color: #888; display: flex; align-items: center; gap: 8px; }

.btn-delete-event-mini {
    position: absolute; top: 10px; right: 10px; border: none; background: transparent;
    color: #ccc; cursor: pointer; padding: 5px; border-radius: 4px; transition: 0.2s;
}
.btn-delete-event-mini:hover { color: #dc3545; background: rgba(220, 53, 69, 0.1); }

/* --- BỐ CỤC CHIA CỘT CHO SECTION LỊCH --- */

/* 1. Khung bao quanh (Container) */
.calendar-layout {
    display: flex;       /* Xếp 2 khối nằm ngang */
    gap: 20px;           /* Khoảng cách giữa 2 cột là 20px */
    align-items: flex-start; /* Căn hàng trên cùng */
    flex-wrap: wrap;     /* Tự xuống dòng nếu màn hình điện thoại quá nhỏ */
}

/* 2. Cột Trái (Lịch hiển thị) - Chiếm phần lớn */
.calendar-main-view {
    flex: 2.5;             /* Chiếm 3 phần không gian (khoảng 70-75%) */
    min-width: 0;        /* Quan trọng: Tránh vỡ khung khi nội dung quá to */
}

/* 3. Cột Phải (Chức năng & Sự kiện) - Chiếm phần nhỏ */
.calendar-side-panel {
    flex: 1.5;             /* Chiếm 1 phần không gian (khoảng 25-30%) */
    min-width: 300px;    /* Đảm bảo cột này không bao giờ bé hơn 300px */
    display: flex;
    flex-direction: column;
    gap: 20px;           /* Khoảng cách giữa các thẻ con trong cột phải */
}

/* --- Responsive cho Mobile --- */
@media (max-width: 768px) {
    .calendar-layout {
        flex-direction: column; /* Trên điện thoại thì xếp dọc lại */
    }
    .calendar-side-panel {
        width: 100%; /* Full màn hình */
    }
}

/* =========================================
   🔔 TOAST NOTIFICATION (THÔNG BÁO GÓC)
   ========================================= */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.custom-toast {
    background: #fff;
    min-width: 300px;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    border-left: 5px solid #2ecc71; /* Màu xanh lá mặc định */
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideInRight 0.3s ease forwards;
    font-size: 15px;
    font-weight: 500;
    color: #333;
}

.custom-toast.error { border-left-color: #dc3545; } /* Màu đỏ nếu lỗi */

.custom-toast i { font-size: 1.2rem; margin-right: 12px; }
.custom-toast .close-toast { cursor: pointer; color: #999; margin-left: 10px; }

@keyframes slideInRight {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOutRight {
    to { transform: translateX(120%); opacity: 0; }
}
/* ==========================================================================
   7. MODULE: CHAT WIDGET
   ========================================================================== */
.chat-widget-container {
  position: fixed; bottom: 25px; right: 25px; z-index: 9999;
  font-family: 'Segoe UI', sans-serif;
}

.chat-btn {
  width: 60px; height: 60px; border-radius: 50%; background-color: #0d6efd;
  color: white; border: none; font-size: 24px; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  cursor: pointer; transition: transform 0.3s; display: flex; align-items: center; justify-content: center;
}
.chat-btn:hover { transform: scale(1.1); }

.chat-badge {
    position: absolute; top: -5px; right: -5px; background: red; color: white;
    font-size: 12px; font-weight: bold; padding: 2px 6px; border-radius: 10px; border: 2px solid white;
}

.chat-box {
  position: absolute; bottom: 80px; right: 0; width: 450px; height: 550px;
  background: white; border-radius: 12px; box-shadow: 0 5px 20px rgba(0,0,0,0.2);
  display: flex; flex-direction: column; overflow: hidden; border: 1px solid #ddd;
  transform-origin: bottom right; /* Đặt tâm xoay ở góc dưới bên phải */
  animation: chatPopup 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); /* Hiệu ứng nảy nhẹ */
}
.chat-box.hidden { display: none; }

.chat-header {
  background: #0d6efd; color: white; padding: 12px 15px; font-weight: bold;
  display: flex; justify-content: space-between; align-items: center;
}
.close-chat-btn { background: transparent; border: none; color: white; cursor: pointer; font-size: 16px; }

.online-count {
    font-size: 13px; font-weight: normal; background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px; border-radius: 12px; margin-left: 8px;
}

.messages-list {
  flex: 1; padding: 15px; overflow-y: auto; background-color: #f8f9fa;
  display: flex; flex-direction: column; gap: 10px;
}

@keyframes chatPopup {
    from { opacity: 0; transform: scale(0.8); } /* Bắt đầu: mờ và nhỏ */
    to { opacity: 1; transform: scale(1); }     /* Kết thúc: rõ và kích thước chuẩn */
}

/* Bubble Styles */
.msg-bubble {
  max-width: 80%; padding: 8px 12px; border-radius: 15px;
  font-size: 14px; line-height: 1.4; word-wrap: break-word; position: relative;
}
.msg-me { align-self: flex-end; background-color: #0d6efd; color: white; border-bottom-right-radius: 2px; }
.msg-other { align-self: flex-start; background-color: #e9ecef; color: #333; border: 1px solid #dee2e6; border-bottom-left-radius: 2px; }
.msg-name { font-size: 11px; color: #666; margin-bottom: 2px; display: block; }

/* Pinned Message */
.msg-bubble.pinned { border: 2px solid #ffc107; background-color: #fffbf0 !important; color: #333 !important; }
.pinned-icon { color: #ffc107; margin-right: 5px; font-size: 12px; }
.pinned-msg-item {
    background: #fff3cd; border-left: 4px solid #ffc107; padding: 10px;
    margin-bottom: 10px; border-radius: 4px; font-size: 0.9em; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Reply Quote */
.reply-quote {
    background: rgba(13, 110, 253, 0.1); border-left: 3px solid #0d6efd;
    padding: 4px 8px; margin-bottom: 6px; border-radius: 4px; font-size: 0.8rem; color: #444;
    display: flex; flex-direction: column;
}
.msg-me .reply-quote { background: rgba(255,255,255,0.6); border-left-color: white; color: #0d2547; }

/* Message Actions & Time */
.msg-time { font-size: 0.65rem; color: #aaa; margin-top: 4px; display: block; text-align: right; font-style: italic; }
.msg-me .msg-time { color: #444 !important; font-weight: bold !important; opacity: 1 !important; }

.msg-container { position: relative; }
.msg-actions { display: inline-block; margin-left: 10px; opacity: 0.6; transition: opacity 0.2s; }
.msg-container:hover .msg-actions { opacity: 1; }
.pin-btn { cursor: pointer; font-size: 11px; color: #666; background: #f1f1f1; padding: 2px 6px; border-radius: 4px; border: 1px solid #ccc; }
.pin-btn:hover { background: #0d6efd; color: white; border-color: #0d6efd; }

/* Reactions */
.reaction-bar { display: flex; gap: 4px; margin-top: -8px; margin-bottom: 4px; z-index: 5; position: relative; padding: 0 10px; }
.reaction-bubble { background: white; border: 1px solid #ddd; border-radius: 12px; padding: 2px 6px; font-size: 0.8rem; box-shadow: 0 1px 2px rgba(0,0,0,0.1); cursor: pointer; }

.emoji-picker-popup {
    position: absolute; background: white; border: 1px solid #ccc; border-radius: 20px;
    padding: 5px; box-shadow: 0 4px 15px rgba(0,0,0,0.15); display: flex; gap: 5px;
    z-index: 100; bottom: 100%; left: 50%; transform: translateX(-50%); white-space: nowrap;
}
.emoji-btn { font-size: 1.2rem; cursor: pointer; transition: transform 0.2s; padding: 2px; }
.emoji-btn:hover { transform: scale(1.3); }
.action-btn-container { position: relative; display: inline-block; }

/* Input Area */
.chat-input-area { padding: 10px; border-top: 1px solid #eee; display: flex; gap: 8px; background: white; }
.chat-input-area input { flex: 1; padding: 8px 12px; border: 1px solid #ddd; border-radius: 20px; outline: none; }
.chat-input-area button { background: #0d6efd; color: white; border: none; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; }
.chat-input-area button:disabled { background: #ccc; }

#reply-preview-bar {
    background: #f0f2f5; padding: 8px 12px; border-top: 1px solid #ddd;
    display: none; justify-content: space-between; align-items: center;
    font-size: 0.9rem; border-left: 4px solid #0d6efd;
}

/* ==========================================================================
   8. MODALS & UTILITIES
   ========================================================================== */
.custom-modal, .modal {
  display: none; position: fixed; z-index: 9999; left: 0; top: 0;
  width: 100%; height: 100%; overflow: auto;
  background-color: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  align-items: center; justify-content: center;
}

.modal-content {
  background-color: #fff; margin: auto; padding: 30px;
  border-radius: 16px; width: 90%; max-width: 600px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
  animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.close-btn { float: right; font-size: 28px; font-weight: bold; cursor: pointer; color: #aaa; transition: color 0.2s; }
.close-btn:hover { color: var(--danger-color); }

.status-message { padding: 15px; border-radius: 8px; font-weight: 500; margin-top: 15px; display: flex; align-items: center; gap: 10px; }
.success-message { background-color: #e6f4ea; color: #137333; }
.error-message { background-color: #fce8e6; color: #c5221f; }


/* ==========================================================================
   1. TOOLBAR & CONTROLS (Thanh công cụ & Nút chuyển view)
   ========================================================================== */
.task-toolbar {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.view-btn {
    border: 1px solid #ddd;
    background: #fff;
    color: #555;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.view-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* ==========================================================================
   2. TABLE STYLES (Giao diện Bảng Monday.com)
   ========================================================================== */
.monday-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 5px;
}

.monday-table th {
    text-align: left;
    padding: 10px;
    color: #666;
    font-size: 0.85rem;
    border-bottom: 2px solid #eee;
}

.monday-table td {
    background: #fff;
    padding: 10px;
    vertical-align: middle;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

/* Bo tròn góc cho dòng đầu và cuối */
.monday-table tr td:first-child {
    border-left: 5px solid transparent;
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
}

.monday-table tr td:last-child {
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
}

/* ==========================================================================
   3. AVATAR STYLES (Hiển thị thành viên)
   ========================================================================== */
.avatar-stack {
    display: flex;
    align-items: center;
}

.member-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50% !important; /* Bắt buộc tròn */
    background-color: #007bff;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    border: 2px solid #fff; /* Viền trắng tách các avatar */
    margin-right: -10px; /* Xếp chồng lên nhau */
    position: relative;
    z-index: 1;
    transition: transform 0.2s, z-index 0.2s;
}

.member-avatar:hover {
    z-index: 10;
    transform: scale(1.1);
}

/* ==========================================================================
   4. CARD VIEW (Giao diện Thẻ Task)
   ========================================================================== */
.task-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.task-card {
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-left: 5px solid #ddd;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.task-card:hover {
    transform: translateY(-3px);
}

.task-card .card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
}

.task-card .card-label {
    font-weight: 600;
    color: #777;
    font-size: 0.85rem;
    min-width: 80px;
}

/* ==========================================================================
   5. MULTI-SELECT DROPDOWN (Chọn nhiều thành viên)
   ========================================================================== */
.multiselect-container {
    position: relative;
    width: 100%;
}

.selectBox {
    position: relative;
    cursor: pointer;
}

.selectBox select {
    width: 100%;
    font-weight: bold;
    color: #333;
    cursor: pointer;
}

.overSelect {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
}

/* Danh sách checkbox ẩn/hiện */
#checkboxes {
    display: none;
    border: 1px solid #ccc;
    border-top: none;
    max-height: 200px;
    overflow-y: auto;
    position: absolute;
    width: 100%;
    background-color: white;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-radius: 0 0 4px 4px;
}

#checkboxes label {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid #f1f1f1;
}

#checkboxes label:hover {
    background-color: #f9f9f9;
}

#checkboxes input {
    margin-right: 10px;
    width: 16px;
    height: 16px;
}

/* ==========================================================================
   6. BADGES & COLORS (Trạng thái & Mức độ ưu tiên)
   ========================================================================== */
.status-badge, .priority-badge {
    display: block;
    width: 100%;
    text-align: center;
    color: white;
    padding: 6px 0;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
}

/* Màu Status */
.bg-done { background-color: #00c875; }
.bg-working { background-color: #fdab3d; }
.bg-stuck { background-color: #e2445c; }
.bg-not-started { background-color: #c4c4c4; }

/* Màu Priority */
.bg-critical { background-color: #333333; }
.bg-high { background-color: #579bfc; }
.bg-medium { background-color: #5559df; }
.bg-low { background-color: #78a9ff; }

div:where(.swal2-container) {
        z-index: 9999 !important;
    }


/* ==========================================================================
   DARK MODE SETTINGS & OVERRIDES (OPTIMIZED)
   (Nền Đen - Nút Tím - Chữ Trắng - Fix Lỗi Hiển Thị)
   ========================================================================== */

/* 1. BIẾN MÀU & CẤU HÌNH CHUNG */
[data-theme="dark"] {
  --primary-color: #8e44ad;       /* Tím (Purple) */
  --primary-hover: #9b59b6;       /* Tím sáng */
  --accent-light: #2c2c3e;        /* Tím than tối */
  
  --bg-body: #121212;             /* Đen sâu */
  --bg-surface: #1e1e1e;          /* Xám đen */
  
  --text-primary: #e0e0e0;        /* Trắng ngà */
  --text-secondary: #b0b0b0;      /* Xám bạc */
  
  --border-color: #333333;        
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.8);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.6);
}

/* 2. ÁP DỤNG MÀU NỀN & CHỮ CƠ BẢN */
[data-theme="dark"] body {
  background-color: var(--bg-body);
  color: var(--text-primary);
}

/* 3. CÁC THÀNH PHẦN KHỐI (Sidebar, Card, Modal, Chat...) */
[data-theme="dark"] #app-sidebar,
[data-theme="dark"] #app-header,
[data-theme="dark"] .card,
[data-theme="dark"] .modal-content,
[data-theme="dark"] #right-sidebar,
[data-theme="dark"] .chat-box,
[data-theme="dark"] .upload-card,
[data-theme="dark"] .filter-card,
[data-theme="dark"] .file-list-card,
[data-theme="dark"] .file-upload-label {
  background-color: var(--bg-surface) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .file-upload-label:hover { background-color: #2c2c2c !important; }

/* 4. FORM ELEMENTS (Input, Select, Textarea) */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] .text-input {
  background-color: #2d2d2d;
  border: 1px solid #444;
  color: #fff;
}
[data-theme="dark"] input:focus, 
[data-theme="dark"] select:focus, 
[data-theme="dark"] textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(142, 68, 173, 0.3);
}
[data-theme="dark"] .form-label, 
[data-theme="dark"] .text-muted { color: #b0b0b0 !important; }

/* 5. TYPOGRAPHY & ICONS (Tiêu đề, Icon) */
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3, 
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6,
[data-theme="dark"] .dashboard-widgets .card h3,
[data-theme="dark"] .dashboard-widgets .card p, 
[data-theme="dark"] .dashboard-widgets .card span,
[data-theme="dark"] .dashboard-widgets .card div {
  color: #fff !important;
}
[data-theme="dark"] .card h3 { color: var(--primary-color) !important; border-bottom-color: var(--border-color); }
[data-theme="dark"] .dashboard-widgets i { color: var(--primary-color); }

/* 6. TABLES (Bảng dữ liệu) */
[data-theme="dark"] .table, [data-theme="dark"] .data-table, [data-theme="dark"] .monday-table {
  background-color: transparent !important; color: var(--text-primary) !important;
}
[data-theme="dark"] th { background-color: #252525 !important; color: #fff !important; border-bottom: 1px solid var(--border-color); }
[data-theme="dark"] td { background-color: var(--bg-surface) !important; color: var(--text-primary) !important; border-color: var(--border-color); }
[data-theme="dark"] tr:hover td { background-color: #2c2c2c !important; }

/* 7. CALENDAR & EVENTS (Lịch) */
[data-theme="dark"] .calendar-container { background: rgba(30, 30, 40, 0.6) !important; border: 1px solid rgba(255,255,255,0.1); box-shadow: none; }
[data-theme="dark"] .calendar-day { background: rgba(255, 255, 255, 0.05) !important; border: 1px solid rgba(255, 255, 255, 0.05) !important; color: #fff !important; }
[data-theme="dark"] .calendar-day:hover { background: rgba(142, 68, 173, 0.3) !important; border-color: #8e44ad !important; }
[data-theme="dark"] .calendar-day.today { border: 2px solid #8e44ad !important; background: rgba(142, 68, 173, 0.2) !important; font-weight: bold; }
[data-theme="dark"] .calendar-day.selected { background: #8e44ad !important; color: #fff !important; box-shadow: 0 0 15px rgba(142, 68, 173, 0.5) !important; }
[data-theme="dark"] .calendar-day.other-month { background: transparent !important; color: #555 !important; border: none !important; }
[data-theme="dark"] .btn-nav-month { background: rgba(255,255,255,0.05) !important; color: #e0e0e0 !important; border: 1px solid #444 !important; }
[data-theme="dark"] .btn-nav-month:hover { background: #8e44ad !important; color: #fff !important; border-color: #8e44ad !important; }

/* Fix Today Calendar Widget (Inline Style) */
[data-theme="dark"] #today-calendar-view li,
[data-theme="dark"] #today-calendar-view > div {
  background: rgba(255, 255, 255, 0.05) !important;
  color: #fff !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-shadow: none !important;
  border-left: 3px solid #8e44ad !important; /* Viền tím */
}
[data-theme="dark"] #today-calendar-view .text-muted,
[data-theme="dark"] #today-calendar-view span,
[data-theme="dark"] #today-calendar-view small { color: #bbb !important; }

/* 8. WIDGETS ĐẶC BIỆT (Ghim, Tiến độ, File) */
/* Tin nhắn ghim */
[data-theme="dark"] .pinned-msg-item, [data-theme="dark"] #chat-pin-view .alert, [data-theme="dark"] #chat-pin-view div {
  background-color: rgba(44, 44, 60, 0.8) !important;
  border-left: 4px solid #8e44ad !important;
  color: #fff !important;
}
[data-theme="dark"] #chat-pin-view i, [data-theme="dark"] .fa-thumbtack { color: #dcdde1 !important; }

/* Tiến độ dự án */
[data-theme="dark"] #project-progress-view, [data-theme="dark"] #project-progress-view h4, 
[data-theme="dark"] #project-progress-view strong, [data-theme="dark"] #project-progress-view a { color: #fff !important; text-decoration: none; }
[data-theme="dark"] .progress-bar-bg { background-color: #333 !important; }
[data-theme="dark"] #project-progress-view .badge { background-color: #8e44ad !important; color: #fff !important; }

/* File & Member */
[data-theme="dark"] #file-insight-view, [data-theme="dark"] #file-insight-view span, [data-theme="dark"] #file-insight-view p { color: #e0e0e0 !important; }
[data-theme="dark"] #myfiles-list-view a { color: #8cb4ff !important; }
[data-theme="dark"] .member-card { background: rgba(255, 255, 255, 0.05) !important; border: 1px solid rgba(255,255,255,0.1) !important; }
[data-theme="dark"] .member-card:hover { background: rgba(142, 68, 173, 0.2) !important; border-color: #8e44ad !important; }
[data-theme="dark"] .member-name { color: #fff !important; }
[data-theme="dark"] .member-status-text { color: #b0b0b0 !important; }
[data-theme="dark"] .text-online { color: #2ecc71 !important; }

/* 9. BOOTSTRAP & BUTTON FIXES */
[data-theme="dark"] .bg-light { background-color: var(--bg-surface) !important; }
[data-theme="dark"] .shadow-sm { box-shadow: 0 1px 2px rgba(0,0,0,0.8) !important; }
[data-theme="dark"] .btn-outline-primary { color: var(--primary-color); border-color: var(--primary-color); }
[data-theme="dark"] .btn-check:checked + .btn-outline-primary { background-color: var(--primary-color); color: #fff; }
[data-theme="dark"] .secondary-btn { background: transparent; color: #fff; border-color: #555; }
[data-theme="dark"] .secondary-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }

/* 10. SCROLLBAR & MENU */
[data-theme="dark"] ::-webkit-scrollbar-track { background: #121212; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: var(--primary-color); }

[data-theme="dark"] .dropdown-menu { background-color: #1e1e1e !important; border: 1px solid #444 !important; }
[data-theme="dark"] .dropdown-item, [data-theme="dark"] #dropdown-username, [data-theme="dark"] .dropdown-item-text { color: #fff !important; }
[data-theme="dark"] .dropdown-item:hover { background-color: #8e44ad !important; color: #fff !important; }

/* ==========================================================================
   DARK MODE RIÊNG CHO CHAT WIDGET (CHATBOX)
   ========================================================================== */

/* 1. Khung Chat (Chat Box Container) */
[data-theme="dark"] .chat-box {
    background-color: #1e1e1e !important; /* Nền tối */
    border: 1px solid #333 !important;    /* Viền tối */
    box-shadow: 0 5px 20px rgba(0,0,0,0.5) !important;
}

/* 2. Header Chat (Thanh tiêu đề xanh/tím) */
[data-theme="dark"] .chat-header {
    background-color: #8e44ad !important; /* Màu TÍM chủ đạo */
    color: #fff !important;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

/* 3. Danh sách tin nhắn (Vùng nội dung) */
[data-theme="dark"] .messages-list {
    background-color: #121212 !important; /* Nền đen sâu hơn khung chat */
}

/* 4. Bong bóng tin nhắn (Message Bubbles) */
/* Tin nhắn của TÔI (Gửi đi) */
[data-theme="dark"] .msg-me {
    background-color: #8e44ad !important; /* Màu TÍM */
    color: #fff !important;
    border: none !important;
}
[data-theme="dark"] .msg-me .msg-time {
    color: rgba(255,255,255,0.7) !important; /* Giờ màu trắng mờ */
}

/* Tin nhắn của NGƯỜI KHÁC (Nhận về) */
[data-theme="dark"] .msg-other {
    background-color: #2c2c2c !important; /* Màu xám tối */
    color: #e0e0e0 !important;            /* Chữ trắng ngà */
    border: 1px solid #444 !important;
}
[data-theme="dark"] .msg-other .msg-name {
    color: #b0b0b0 !important; /* Tên người gửi màu xám sáng */
}
[data-theme="dark"] .msg-other .msg-time {
    color: #888 !important;    /* Giờ màu xám tối */
}

/* 5. Khu vực nhập liệu (Input Area) */
[data-theme="dark"] .chat-input-area {
    background-color: #1e1e1e !important;
    border-top: 1px solid #333 !important;
}

[data-theme="dark"] .chat-input-area input {
    background-color: #2d2d2d !important; /* Input nền tối */
    color: #fff !important;
    border: 1px solid #444 !important;
}

[data-theme="dark"] .chat-input-area input:focus {
    border-color: #8e44ad !important; /* Focus viền tím */
}

/* Nút gửi (Send Button) */
[data-theme="dark"] .chat-input-area button {
    background-color: #8e44ad !important; /* Nút tím */
    color: #fff !important;
}
[data-theme="dark"] .chat-input-area button:disabled {
    background-color: #444 !important;    /* Nút vô hiệu hóa màu xám */
    color: #888 !important;
}

/* 6. Tin nhắn được Ghim (Pinned Message) */
[data-theme="dark"] .msg-bubble.pinned,
[data-theme="dark"] .pinned-msg-item {
    background-color: rgba(44, 44, 60, 0.9) !important; /* Nền tím than */
    border: 1px solid #8e44ad !important;
    color: #fff !important;
}
[data-theme="dark"] .pinned-icon {
    color: #dcdde1 !important; /* Icon ghim màu bạc */
}

/* 7. Trích dẫn trả lời (Reply Quote) */
[data-theme="dark"] .reply-quote {
    background-color: rgba(255, 255, 255, 0.1) !important;
    border-left-color: #b0b0b0 !important;
    color: #ccc !important;
}
[data-theme="dark"] .msg-me .reply-quote {
    background-color: rgba(0, 0, 0, 0.2) !important; /* Quote trong tin nhắn tím */
    border-left-color: rgba(255,255,255,0.5) !important;
    color: #e0e0e0 !important;
}

/* Thanh xem trước khi trả lời (Reply Preview Bar) */
[data-theme="dark"] #reply-preview-bar {
    background-color: #252525 !important;
    color: #fff !important;
    border-top: 1px solid #333 !important;
    border-left: 4px solid #8e44ad !important;
}

/* 8. Emoji & Reaction */
[data-theme="dark"] .emoji-picker-popup {
    background-color: #1e1e1e !important;
    border-color: #444 !important;
}
[data-theme="dark"] .reaction-bubble {
    background-color: #2c2c2c !important;
    border-color: #444 !important;
    color: #fff !important;
}
