/* ==========================================================================
   MYSELLER BOS - CẤU HÌNH ADMIN DASHBOARD (CLEANED)
   ========================================================================== */
:root {
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --bg-color: #f1f5f9;
    --primary-color: #4E220F;
    --primary-hover: #0f172a;
    --accent-color: #2563eb;
    --text-color: #334155;
    --sidebar-text: #ecf0f1;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --white: #ffffff;
    --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.12);
    --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* BASE RESET DÀNH CHO ADMIN */
body.bos-admin-body { 
    font-family: 'Inter', 'Segoe UI', sans-serif; 
    background-color: var(--bg-color); 
    color: var(--text-color); 
    line-height: 1.6; 
}

/* 1. LAYOUT QUẢN TRỊ (BOS MAIN) */
.bos-layout { display: flex; min-height: 100vh; }

.bos-sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-color); 
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: all 0.3s;
}

.bos-sidebar .brand {
    padding: 20px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.bos-sidebar .menu { padding: 3px 0; flex: 1; }

.menu-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 12px 25px 6px 25px; 
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #F5E6D3;
    letter-spacing: 1.2px;
    transition: color 0.25s ease, background-color 0.25s ease, padding-left 0.25s ease;
    border-radius: 6px;
}

.menu-label:hover { color: #FFFFFF; background-color: rgba(255, 255, 255, 0.08); padding-left: 28px; }
.menu-label:active { transform: scale(0.98); }
.menu-label .chevron { transition: transform 0.25s ease; font-size: 0.9rem; display: inline-block; }

.menu-group .menu-items { max-height: 500px; overflow: hidden; transition: max-height 0.3s cubic-bezier(0, 1, 0, 1), opacity 0.25s ease; opacity: 1; }
.menu-group.collapsed .menu-items { max-height: 0; opacity: 0; }
.menu-group.collapsed .chevron { transform: rotate(-90deg); }

.bos-sidebar .menu a { padding: 12px 25px; display: block; color: #d1d5db; transition: all 0.2s ease; text-decoration: none; }
.bos-sidebar .menu a:hover { background: #1f2937 !important; color: #ffffff !important; padding-left: 30px; }
.bos-sidebar .menu a.active-bos { background: #2563eb !important; color: #ffffff !important; font-weight: 600; border-left: 4px solid #3b82f6 !important; }
.bos-sidebar .menu a.active-los { background: #10b981 !important; color: #ffffff !important; font-weight: 600; border-left: 4px solid #34d399 !important; }
.bos-sidebar .menu a i { margin-right: 10px; width: 20px; text-align: center; }

.bos-container { 
    margin-left: var(--sidebar-width); 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    padding-top: var(--topbar-height); /* Đẩy nội dung xuống không bị header che */
    padding-bottom: 70px; /* Thêm dòng này để tránh bị footer che khuất nội dung phía dưới */
}

.bos-header { 
    height: var(--topbar-height); 
    background: var(--white); 
    padding: 0 25px; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); 
    border-bottom: 1px solid #e2e8f0; 
    box-sizing: border-box; 
    position: fixed; 
    top: 0; 
    left: var(--sidebar-width); 
    width: calc(100% - var(--sidebar-width)); 
    z-index: 999; 
}

.header-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.bos-view-port { padding: 5px; }

/* WIDGETS & STATS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: var(--white); padding: 20px; border-radius: 8px; box-shadow: var(--shadow-soft); }
.stat-card h3 { font-size: 0.9rem; color: #7f8c8d; }
.stat-card .value { font-size: 1.8rem; font-weight: bold; color: var(--primary-color); margin-top: 5px; }

.factory-badge { background: rgba(0,0,0,0.2); margin: 10px 20px; padding: 8px 15px; border-radius: 6px; font-size: 0.8rem; color: var(--accent-color); display: flex; align-items: center; gap: 10px; }

/* RIBBON & TABS */
.system-ribbon { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.system-tab { padding: 7px 18px; border-radius: 8px; cursor: pointer; font-size: .9rem; font-weight: 600; color: #64748b; transition: var(--transition-smooth); user-select: none; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.system-tab:hover { background: #eef4ff; color: var(--primary-color); }
.system-tab.active-bos { background: #2563eb !important; color: #ffffff !important; }
.system-tab.active-los { background: #10b981 !important; color: #ffffff !important; }
.system-tab:active { transform: scale(0.97); }

#module-name { font-size: 1.05rem; font-weight: 600; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left: 4px; }
.header-right { display: flex; align-items: center; flex-shrink: 0; margin-left: 12px; }
.user-info { margin-right: 15px; font-weight: 600; color: var(--primary-color); }
.logout-btn { background: #687FE5; color: #fff; padding: 6px 15px; border-radius: 4px; font-size: .85rem; display: inline-flex; align-items: center; gap: 5px; transition: var(--transition-smooth); font-weight: 500; }
.logout-btn:hover { background: #fff5f5; color: black; box-shadow: 0 2px 8px rgba(231, 76, 60, 0.2); }
.btn-view-public { background: rgba(56, 189, 248, 0.1) !important; color: #38bdf8 !important; border: 1px solid rgba(56, 189, 248, 0.2); border-radius: 6px; margin: 10px 15px !important; font-weight: 600; }
.btn-view-public:hover { background: #38bdf8 !important; color: #ffffff !important; }

/* ROLES & STAFF MANAGEMENT */
.role-badge { font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; margin-left: 5px; text-transform: uppercase; }
.role-owner { background: #dcfce7; color: #166534; }
.role-staff { background: #fef9c3; color: #854d0e; }
.staff-mgmt-container { padding: 24px; max-width: 1200px; margin: 0 auto; box-sizing: border-box; }
.staff-mgmt-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 16px; }
.staff-mgmt-title h2 { margin: 0; font-size: 1.5rem; color: #1e293b; }
.staff-mgmt-title p { margin: 4px 0 0 0; font-size: 0.875rem; color: #64748b; }
.btn-add-permission { background: #10b981; color: #fff; border: none; padding: 10px 16px; border-radius: 6px; cursor: pointer; font-weight: 500; display: flex; align-items: center; gap: 8px; white-space: nowrap; transition: background 0.2s ease; }
.btn-add-permission:hover { background: #059669; }

.staff-table-responsive { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); border: 1px solid #e2e8f0; overflow-x: auto; width: 100%; -webkit-overflow-scrolling: touch; }
.staff-table-responsive table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.95rem; min-width: 900px; }

/* MODALS */
.staff-modal-overlay { display: none; position: fixed; z-index: 9999; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); align-items: center; justify-content: center; padding: 16px; box-sizing: border-box; }
.staff-modal-content { background: #fff; padding: 24px; border-radius: 8px; width: 100%; max-width: 500px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); border: 1px solid #e2e8f0; position: relative; box-sizing: border-box; max-height: 90vh; overflow-y: auto; }
.staff-modal-grid-2 { display: flex; gap: 12px; margin-bottom: 14px; }
.staff-modal-grid-2 > div { flex: 1; }

.mobile-menu-toggle { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; padding: 8px; border-radius: 6px; transition: var(--transition-smooth); }
.mobile-menu-toggle:hover { background: #f1f5f9; }
.sidebar-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(15, 23, 42, 0.4); z-index: 998; display: none; opacity: 0; transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1); backdrop-filter: blur(2px); }

/* ==========================================================================
   MAIN FOOTER STICKY (CỐ ĐỊNH DƯỚI ĐÁY MÀN HÌNH)
   ========================================================================== */
.footer_main_container {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width); /* Tránh đè lên sidebar trên desktop */
    width: calc(100% - var(--sidebar-width));
    background-color: var(--primary-color, #1e293b); /* Dùng màu nền tối chủ đạo của hệ thống để nổi bật */
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    text-align: center;
    color: #ffffff; /* Đổi màu chữ sang trắng sáng để tương phản tuyệt đối với nền tối */
    font-size: 0.85rem;
    font-weight: 500; /* Tăng độ đậm nhẹ giúp chữ sắc nét hơn */
    padding: 12px 20px;
    box-sizing: border-box;
    z-index: 998; 
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1); /* Đổ bóng đậm hơn tách biệt hẳn với nội dung */
}

.footer_main_content {
    margin: 0 auto;
    max-width: 1200px;
}

/* Đảm bảo nội dung trang không bị footer cố định che khuất phần cuối */
body.bos-admin-body {
    padding-bottom: 55px; 
}

/* RESPONSIVE BREAKPOINTS (ADMIN) */
/*
@media(max-width: 1024px) {
    .mobile-menu-toggle { display: inline-flex; }
    .bos-sidebar { position: fixed; top: 0; left: 0; height: 100vh; width: var(--sidebar-width); z-index: 999; transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
    .bos-sidebar.active { transform: translateX(0); }
    .sidebar-overlay.active { display: block; opacity: 1; }
    
    .bos-container { margin-left: 0 !important; width: 100% !important; }
    
    .bos-header {
        left: 0 !important;
        width: 100% !important;
    }
    
    .system-ribbon { margin-left: 8px; gap: 4px; }
    .system-tab { padding: 6px 10px; font-size: .82rem; }
    .footer_main_container {
        left: 0 !important;
        width: 100% !important;
    }
}
*/

@media(max-width: 1024px) {
    .mobile-menu-toggle { display: inline-flex; }
    
    /* Đẩy z-index lên cao hơn header (999) và overlay (998) để sidebar nằm trên cùng */
    .bos-sidebar { 
        position: fixed; 
        top: 0; 
        left: 0; 
        height: 100vh; 
        width: var(--sidebar-width); 
        z-index: 1002 !important; /* Tăng z-index để đè lên header */
        transform: translateX(-100%); 
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    }
    .bos-sidebar.active { transform: translateX(0); }
    .sidebar-overlay.active { display: block; opacity: 1; z-index: 1001; /* Overlay nằm dưới sidebar nhưng trên header */ }
    
    .bos-container { margin-left: 0 !important; width: 100% !important; }
    .bos-header {
        left: 0 !important;
        width: 100% !important;
        z-index: 999; /* Header thấp hơn sidebar */
    }
    
    .system-ribbon { margin-left: 8px; gap: 4px; }
    .system-tab { padding: 6px 10px; font-size: .82rem; }
    .footer_main_container {
        left: 0 !important;
        width: 100% !important;
    }
}

@media (max-width: 767px) {
    .bos-sidebar { transform: translateX(-100%); }       
    .bos-container { margin-left: 0 !important; width: 100% !important; }
    
    /* Đảm bảo header luôn bám sát đỉnh và rộng toàn màn hình trên điện thoại */
    .bos-header { 
        left: 0 !important;
        width: 100% !important;
        padding: 8px 12px; 
        min-height: 54px; 
    }
    
    .bos-header { padding: 8px 12px; min-height: 54px; }
    .header-left { gap: 8px; }
    .system-tab { padding: 5px 10px; font-size: 0.8rem; }
    #module-name { font-size: 0.85rem; max-width: 120px; }
    .logout-btn { padding: 6px 10px; }
    .staff-mgmt-container { padding: 16px; }
    .staff-mgmt-header { flex-direction: column; align-items: flex-start; }
    .btn-add-permission { width: 100%; justify-content: center; }
    .staff-modal-grid-2 { flex-direction: column; gap: 14px; }
    .menu-label .chevron { font-size: 1.25rem; font-weight: bold; padding: 0 4px; }
}
