/* --- BIẾN MÀU & THIẾT LẬP CHUNG --- */
:root {
    --primary-color: #4f46e5;
    --secondary-color: #6366f1;
    --bg-color: #f1f5f9;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-text-hover: #ffffff;
    --card-bg: #ffffff;
    --text-color: #334155;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Be Vietnam Pro', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
}

/* --- BỐ CỤC CHÍNH --- */
.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* --- HIỆU ỨNG VÀ GIAO DIỆN SIDEBAR --- */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease-in-out;

    /* ===== THÊM CÁC DÒNG NÀY VÀO ===== */
    position: sticky; /* Giúp menu "dính" lại khi cuộn */
    top: 0;           /* Dính vào cạnh trên của màn hình */
    height: 100vh;    /* Đặt chiều cao bằng 100% chiều cao màn hình */
    overflow-y: auto; /* Tự động thêm thanh cuộn nếu menu quá dài */
}

.sidebar.collapsed {
    width: 80px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    padding: 20px;
    font-size: 1.5rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-header i {
    min-width: 40px;
    text-align: center;
    font-size: 1.8rem;
    color: var(--secondary-color);
}

.sidebar-nav {
    flex-grow: 1;
    margin-top: 20px;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    transition: background-color 0.2s ease, color 0.2s ease, padding-left 0.3s ease;
}

.sidebar-nav a:hover {
    background-color: rgba(79, 70, 229, 0.5);
    color: var(--sidebar-text-hover);
}

.sidebar-nav a.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: 700;
    border-left: 4px solid var(--secondary-color);
    padding-left: 16px;
}

.sidebar-nav a i {
    min-width: 40px;
    font-size: 1.2rem;
    text-align: center;
    transition: transform 0.3s ease;
}

.sidebar-nav a:hover i {
    transform: scale(1.1);
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .sidebar-header-text {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
}

.sidebar-footer {
    padding-bottom: 20px;
}

/* --- HIỆU ỨNG VÀ GIAO DIỆN NỘI DUNG CHÍNH --- */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease-in-out;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background-color: var(--card-bg);
    box-shadow: 0 2px 4px var(--shadow-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.menu-toggle-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
    transition: transform 0.3s ease, color 0.2s ease;
}

.menu-toggle-btn:hover {
    color: var(--primary-color);
    transform: rotate(90deg);
}

.page-title {
    font-size: 1.8rem;
    font-weight: 700;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-profile img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

.content-wrapper {
    padding: 30px;
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
}

.card {
    background-color: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 10px var(--shadow-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.card-icon {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.card h3 {
    margin-bottom: 5px;
    font-size: 1.8rem;
    font-weight: 700;
}

.card p {
    font-size: 1rem;
    color: #64748b;
}

.placeholder-content {
    background-color: var(--card-bg);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 10px var(--shadow-color);
    min-height: 300px;
}

/* --- KIỂU RIÊNG CHO NÚT ĐĂNG XUẤT --- */
.sidebar-footer {
    padding: 20px;
    margin-top: auto; /* Đẩy nút xuống dưới cùng */
}

.logout-btn {
    display: flex; /* QUAN TRỌNG: Biến nút thành flex container */
    align-items: center; /* Căn giữa icon và chữ theo chiều dọc */
    gap: 10px; /* Thêm khoảng cách 10px giữa icon và chữ */
    
    background-color: rgba(220, 38, 38, 0.2);
    color: #fca5a5 !important;
    border: 1px solid #ef4444;
    border-radius: 8px;
    font-weight: 700 !important;
    text-decoration: none;
    padding: 12px; /* Tăng padding cho nút cân đối hơn */
}

.logout-btn:hover {
    background-color: #dc2626 !important;
    color: #ffffff !important;
    border-color: #b91c1c;
}

.logout-btn i {
    transform: none !important;
}

/* --- GIAO DIỆN FORM VÀ BẢNG SẢN PHẨM --- */

/* Thẻ card chung */
.card {
    margin-bottom: 30px;
}
.card h3 {
    font-size: 1.2rem;
    margin-bottom: 20px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 10px;
}
.card h3 i {
    margin-right: 8px;
    color: var(--primary-color);
}

/* Form thêm sản phẩm */
.product-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 1rem;
    font-family: 'Be Vietnam Pro', sans-serif;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.btn-submit {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 15px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-submit:hover {
    background-color: var(--secondary-color);
}

/* Bảng sản phẩm */
.table-wrapper {
    overflow-x: auto; /* Giúp bảng responsive trên màn hình nhỏ */
}

.product-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.product-table th,
.product-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.product-table thead th {
    background-color: #f8fafc;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-color);
}

.product-table tbody tr:hover {
    background-color: #f1f5f9;
}

/* Nút hành động trong bảng */
.action-buttons a {
    text-decoration: none;
    color: #64748b;
    margin-right: 15px;
    font-size: 1.1rem;
    transition: color 0.2s ease;
}
.action-buttons a:last-child {
    margin-right: 0;
}
.action-buttons .btn-edit:hover {
    color: var(--primary-color);
}
.action-buttons .btn-delete:hover {
    color: #dc2626;
}

/* Thông báo */
.notice {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 6px;
    border: 1px solid;
}
.notice.success {
    background-color: #dcfce7;
    border-color: #4ade80;
    color: #166534;
}

/* --- CSS CHO CHỨC NĂNG SỬA TRỰC TIẾP --- */

/* Thêm con trỏ và hiệu ứng cho các ô có thể sửa */
.editable {
    cursor: pointer;
    position: relative;
}

.editable:hover::after {
    content: '✏️';
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8em;
    opacity: 0.6;
}

/* Kiểu cho ô input/select khi xuất hiện trong bảng */
.product-table input,
.product-table select {
    width: 100%;
    padding: 8px;
    font-size: 1em;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    font-family: 'Be Vietnam Pro', sans-serif;
    box-sizing: border-box; /* Quan trọng để không làm vỡ layout */
}
/* --- SỬA LỖI VÀ KẺ VIỀN BẢNG RÕ RÀNG --- */

/* Thiết lập chế độ gộp viền cho bảng */
.product-table {
    border-collapse: collapse; /* Đây là thuộc tính quan trọng nhất */
    width: 100%;
}

/* Áp dụng viền cho tất cả các ô (header và data) */
.product-table th,
.product-table td {
    border: 1px solid #e2e8f0; /* Một quy tắc duy nhất cho tất cả viền */
    padding: 15px;
    text-align: left;
}

/* Đảm bảo header có nền và chữ đậm */
.product-table thead th {
    background-color: #f8fafc;
    font-weight: 700;
}

/* --- KIỂU DÁNG CHO TOAST NOTIFICATION --- */
#toast-notification {
    position: fixed; /* Luôn hiển thị trên màn hình */
    top: 25px;
    right: 25px;
    background-color: #28a745; /* Màu xanh lá cây thành công */
    color: white;
    padding: 16px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    font-weight: 500;
    z-index: 9999;

    /* Trạng thái ẩn ban đầu */
    opacity: 0;
    visibility: hidden;
    transform: translateX(100%);
    transition: all 0.4s ease-in-out;
}

/* Trạng thái hiện khi có class 'show' */
#toast-notification.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}
/* --- CSS CHO NHÓM CHECKBOX DỊCH VỤ THÊM --- */
.checkbox-group {
    display: flex;
    gap: 20px;
    align-items: center;
    padding-top: 10px; /* Căn chỉnh với các ô khác */
}
.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
}

/* --- CSS CHO MODAL SỬA ĐƠN HÀNG --- */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; 
    background-color: rgba(0,0,0,0.5);
}
.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 700px;
    border-radius: 8px;
    animation-name: slideIn;
    animation-duration: 0.4s
}
@keyframes slideIn {
    from {top: -300px; opacity: 0}
    to {top: 10%; opacity: 1}
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
    margin-bottom: 20px;
}
.close-modal {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
.close-modal:hover {
    color: black;
}

/* --- CSS CHO TRANG BÁO CÁO (CẬP NHẬT) --- */
.report-card.success .card-icon {
    color: #28a745; /* Màu xanh thành công */
}

/* Thêm mới */
.report-card.shipping .card-icon {
    color: #ffc107; /* Màu vàng đang xử lý */
}

.report-card.danger .card-icon {
    color: #dc3545; /* Màu đỏ nguy hiểm/thiệt hại */
}

.report-card h3 {
    font-size: 2.2rem;
}
/* --- CSS CHO LINK BÁO CÁO --- */
.report-link {
    text-decoration: none; /* Bỏ gạch chân của link */
    color: inherit; /* Kế thừa màu chữ mặc định */
}

.report-link .card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.report-link:hover .card {
    transform: translateY(-5px); /* Hiệu ứng nhấc lên khi di chuột vào */
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* --- CSS CHO BẢNG ĐIỀU KHIỂN MỚI --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Biểu đồ chiếm 2/3, đơn hàng gần đây 1/3 */
    gap: 30px;
    margin-top: 30px;
}

.chart-container, .recent-orders-container {
    padding: 25px;
}

/* Bảng đơn hàng gần đây */
.product-table.simple {
    margin-top: 15px;
}

.product-table.simple th,
.product-table.simple td {
    padding: 12px 10px;
}

/* Huy hiệu trạng thái */
.status-badge {
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.6rem;
    font-weight: 700;
    color: black;
}
.status-badge.da-giao-hang { background-color: #28a745; }
.status-badge.dang-giao { background-color: #ffc107; color: #333}
.status-badge.dang-chuan-bi-hang { background-color: #17a2b8; }
.status-badge.hoan-tra { background-color: #dc3545; }


/* Responsive cho màn hình nhỏ */
@media (max-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 1fr; /* Xếp chồng lên nhau */
    }
}