/* ============================================================
   RESET & BASE
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: #f0f4f9;
    color: #1a2639;
    min-height: 100vh;
    display: flex;
    transition: background 0.3s, color 0.3s;
}

/* ============================================================
   THEME DARK / LIGHT (giữ cơ chế cũ nhưng màu mới)
   ============================================================ */
:root {
    --bg-body: #f0f4f9;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8faff;
    --bg-header: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1a2639;
    --text-secondary: #3e4a5e;
    --text-muted: #7a8aa0;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 8px 30px rgba(0,0,0,0.08);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.10);
    --radius: 20px;
    --radius-sm: 12px;
    --accent: #2a7de1;
    --accent-light: #6ba6ff;
    --accent-dark: #1a5bbf;
    --green: #10b981;
    --green-bg: #e6faf5;
    --orange: #f59e0b;
    --orange-bg: #fef3e2;
    --red: #ef4444;
    --red-bg: #fde8e8;
    --blue: #3b82f6;
    --blue-bg: #e6effe;
    --purple: #8b5cf6;
    --purple-bg: #f0ebff;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-body: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-card: #1e293b;
    --bg-card-hover: #2d3a52;
    --bg-header: #1e293b;
    --border-color: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 8px 30px rgba(0,0,0,0.4);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.6);
    --green-bg: #0f2e26;
    --orange-bg: #2f2413;
    --red-bg: #2e1a1a;
    --blue-bg: #14263b;
    --purple-bg: #1e1b3a;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 4px; }

/* ============================================================
   SIDEBAR – thu gọn, nền trắng, icon lớn
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 240px;
    height: 100%;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    padding: 24px 16px 30px;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.4s ease, background 0.3s, border-color 0.3s;
    transform: translateX(0);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}
.sidebar.closed {
    transform: translateX(-100%);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 28px;
}
.sidebar-brand img {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: var(--accent);
    box-shadow: 0 4px 12px rgba(42, 125, 225, 0.3);
}
.sidebar-brand span {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.sidebar-nav {
    flex: 1;
}
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all var(--transition);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: 'Inter', sans-serif;
    position: relative;
}
.sidebar-nav .nav-link:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}
.sidebar-nav .nav-link.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 16px rgba(42, 125, 225, 0.3);
}
.sidebar-nav .nav-link i {
    width: 24px;
    font-size: 18px;
    text-align: center;
}
.sidebar-nav .nav-link .arrow {
    margin-left: auto;
    transition: transform 0.3s;
    font-size: 12px;
}
.sidebar-nav .nav-link .arrow.open {
    transform: rotate(180deg);
}

.sidebar-nav .submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 0;
    margin-left: 22px;
    padding-left: 14px;
    border-left: 2px solid var(--border-color);
}
.sidebar-nav .submenu.open {
    max-height: 300px;
    opacity: 1;
    margin-bottom: 6px;
}
.sidebar-nav .submenu .nav-link {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 400;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-footer .badge {
    background: var(--green);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 12px;
    border-radius: 30px;
}

/* ============================================================
   OVERLAY
   ============================================================ */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* ============================================================
   MAIN – content rộng, không có margin-left nếu sidebar đóng
   ============================================================ */
.main {
    flex: 1;
    margin-left: 240px;
    min-height: 100vh;
    transition: margin-left 0.4s ease;
    display: flex;
    flex-direction: column;
}
.main.expanded {
    margin-left: 0;
}

/* ============================================================
   HEADER – đơn giản, có thanh tìm kiếm
   ============================================================ */
.header {
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    padding: 14px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 70px;
    transition: background 0.3s, border-color 0.3s;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 18px;
}
.hamburger {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.2s;
}
.hamburger:hover {
    transform: scale(1.1);
}
.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 40px;
    padding: 6px 18px;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(42,125,225,0.15);
}
.search-box i {
    color: var(--text-muted);
    font-size: 16px;
    margin-right: 10px;
}
.search-box input {
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    width: 220px;
}
.search-box input::placeholder {
    color: var(--text-muted);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}
.header-right .icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.2s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.header-right .icon-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}
.avatar-wrap {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
}
.avatar-wrap img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}
.avatar-wrap .online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--green);
    border-radius: 50%;
    border: 2px solid var(--bg-header);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.25s ease;
    z-index: 200;
}
.dropdown-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    font-size: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.2s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
}
.dropdown-menu .dropdown-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}
.dropdown-menu .dropdown-item i {
    width: 20px;
    color: var(--text-muted);
}
.dropdown-menu .user-info {
    padding: 8px 20px 14px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
}
.dropdown-menu .user-info .name {
    font-weight: 700;
    color: var(--text-primary);
}

/* ============================================================
   CONTENT – Dashboard kiểu mới
   ============================================================ */
.content {
    padding: 32px 36px 44px;
    flex: 1;
}

.page-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.page-title h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}
.page-title .date-range {
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-card);
    padding: 8px 20px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
}

/* ===== STATS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 36px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px 26px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}
.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}
.stat-card .stat-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.stat-card .stat-label i {
    font-size: 16px;
    color: var(--accent);
}
.stat-card .stat-value {
    font-size: 36px;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 6px;
    line-height: 1.2;
}
.stat-card .stat-change {
    font-size: 13px;
    font-weight: 600;
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 14px;
    border-radius: 20px;
}
.stat-card .stat-change.up {
    background: var(--green-bg);
    color: var(--green);
}
.stat-card .stat-change.down {
    background: var(--red-bg);
    color: var(--red);
}
.stat-card .stat-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== WIDGETS 2 cột ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 28px;
}

/* Bảng dữ liệu */
.table-wrap {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 20px 24px 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s;
}
.table-wrap:hover {
    box-shadow: var(--shadow-md);
}
.table-wrap .table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.table-wrap .table-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}
.table-wrap .table-header h3 i {
    color: var(--accent);
}
.table-wrap .table-header .view-all {
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}
.table-wrap .table-header .view-all:hover {
    color: var(--accent-dark);
}
.table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.table-wrap table thead th {
    text-align: left;
    padding: 10px 4px 14px 4px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}
.table-wrap table tbody td {
    padding: 14px 4px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}
.table-wrap table tbody tr:last-child td {
    border-bottom: none;
}
.table-wrap table tbody tr:hover {
    background: var(--bg-card-hover);
}
.table-wrap .status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 14px 2px 12px;
    border-radius: 30px;
    font-size: 12px;
    font-weight: 600;
}
.status-badge.success {
    background: var(--green-bg);
    color: var(--green);
}
.status-badge.warning {
    background: var(--orange-bg);
    color: var(--orange);
}
.status-badge.danger {
    background: var(--red-bg);
    color: var(--red);
}
.status-badge.info {
    background: var(--blue-bg);
    color: var(--blue);
}
.status-badge.purple {
    background: var(--purple-bg);
    color: var(--purple);
}
.table-wrap .amount {
    font-weight: 700;
    color: var(--text-primary);
}

/* Widget bên phải: hoạt động gần đây */
.activity-widget {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 20px 24px 24px;
    box-shadow: var(--shadow-sm);
}
.activity-widget h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.activity-widget h3 i {
    color: var(--accent);
}
.activity-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}
.activity-item:last-child {
    border-bottom: none;
}
.activity-item .activity-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--blue-bg);
    color: var(--blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.activity-item .activity-content {
    flex: 1;
}
.activity-item .activity-content .title {
    font-weight: 600;
    color: var(--text-primary);
}
.activity-item .activity-content .desc {
    font-size: 13px;
    color: var(--text-muted);
}
.activity-item .activity-time {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar { width: 260px; }
    .main { margin-left: 0; }
    .header { padding: 10px 16px; flex-wrap: wrap; }
    .search-box input { width: 140px; }
    .header-center { display: none; }
    .content { padding: 20px 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 16px; }
    .stat-card .stat-value { font-size: 28px; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-title h1 { font-size: 22px; }
    .search-box { display: none; }
}