/* ==========================================================================
   1. BIẾN MÀU THEME (HỖ TRỢ LIGHT / DARK MODE)
   ========================================================================== */
:root {
  /* Light Mode (Mặc định) */
  --bg-primary: #f8fafc;        /* Nền tổng thể: xám siêu nhạt */
  --bg-secondary: #ffffff;      /* Nền phụ (Sidebar, Header) */
  --bg-card: #ffffff;           /* Nền thẻ */
  
  --text-primary: #0f172a;      /* Chữ chính: xanh đen đậm */
  --text-secondary: #64748b;    /* Chữ phụ: xám */
  
  --border-color: #e2e8f0;      /* Viền nhạt */
  --border-hover: #cbd5e1;      /* Viền khi hover */
  
  --accent-color: #0f172a;      /* Nút bấm (Đen) */
  --accent-text: #ffffff;       /* Chữ trên nút bấm (Trắng) */
  
  --brand-primary: #4f46e5;     /* Xanh Tím (Màu thương hiệu) */
  --brand-secondary: #9333ea;   /* Tím Gradient */
  --success-color: #10b981;     /* Xanh lá (Tiền bạc) */
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  --radius-md: 8px;
  --radius-lg: 16px;            /* Bo góc mềm mại kiểu Premium */

  /* Biến phụ trợ cho phần Header/Footer dùng chung */
  --primary-blue: #0052FF;
  --primary-blue-hover: #0040cc;
  --footer-bg: #0B1120;
}

[data-theme="dark"] {
  /* Dark Mode */
  --bg-primary: #0b0f19;        /* Nền tổng thể: Đen tuyền */
  --bg-secondary: #111827;      /* Nền phụ */
  --bg-card: #1f2937;           /* Nền thẻ */
  
  --text-primary: #f8fafc;      /* Chữ chính: Trắng sáng */
  --text-secondary: #94a3b8;    /* Chữ phụ: Xám nhạt */
  
  --border-color: #334155;      /* Viền tối */
  --border-hover: #475569;      /* Viền khi hover tối */
  
  --accent-color: #ffffff;      /* Nút bấm (Trắng) */
  --accent-text: #0f172a;       /* Chữ trên nút bấm (Đen) */
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.7);
}

/* ==========================================================================
   2. RESET & CẤU HÌNH GỐC
   ========================================================================== */
* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease; 
}
body { 
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
  background-color: var(--bg-primary); 
  color: var(--text-primary); 
  line-height: 1.5; 
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }

.vlemp-container { 
  max-width: 1200px !important; 
  margin: 0 auto !important; 
  padding: 0 20px !important; 
  width: 100% !important;
}
.logo img {
    max-width: 100%;
}
/* ==========================================================================
   3. HEADER & ĐIỀU HƯỚNG CHUNG
   ========================================================================== */
.main-header { 
  background: var(--bg-secondary); padding: 15px 0; position: sticky; 
  top: 0; z-index: 100; box-shadow: var(--shadow-sm); width: 100%; 
  border-bottom: 1px solid var(--border-color);
}
.header-inner { display: flex !important; justify-content: space-between !important; align-items: center !important; }

.header-left { flex: 1; display: flex; justify-content: flex-start; }
.header-center { flex: 2; display: flex; justify-content: center; }
.header-right { flex: 1; display: flex; justify-content: flex-end; }

.logo { font-size: 1.25rem; font-weight: 800; color: var(--text-primary); display: flex; align-items: center; gap: 8px; white-space: nowrap; letter-spacing: -0.5px; }
.logo i { color: var(--primary-blue); font-size: 1.5rem; }

.nav-links { display: flex; gap: 30px; font-weight: 500; font-size: 0.95rem; align-items: center; margin: 0; padding: 0; }
.nav-links a { color: var(--text-primary); transition: color 0.2s; white-space: nowrap; }
.nav-links a:hover { color: var(--primary-blue); }

.nav-controls { display: flex; align-items: center; gap: 12px; }

/* Các nút bấm (Buttons) */
.btn-control { 
  background: var(--bg-primary); border: 1px solid var(--border-color); 
  color: var(--text-primary); padding: 8px 14px; border-radius: var(--radius-md); 
  cursor: pointer; font-size: 0.9rem; font-weight: 500; display: flex; align-items: center; gap: 6px;
}
.btn-control:hover { border-color: var(--border-hover); background: var(--bg-card); }

.btn-primary { 
  background: var(--accent-color); color: var(--accent-text); border: none; 
  padding: 12px 20px; border-radius: var(--radius-md); font-weight: 600; 
  cursor: pointer; text-align: center; display: inline-block; width: 100%;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-login { color: var(--text-primary); font-weight: 600; padding: 8px 15px; white-space: nowrap; }
.btn-register { background: var(--primary-blue); color: white; padding: 10px 20px; border-radius: 8px; font-weight: 600; transition: 0.2s; white-space: nowrap; border: none; cursor: pointer; display: inline-flex; justify-content: center; align-items: center; gap: 8px;}
.btn-register:hover { background: var(--primary-blue-hover); color: white; }

/* Form Inputs */
input[type="text"], input[type="email"], input[type="password"] {
  width: 100%; padding: 12px 15px; border: 1px solid var(--border-color);
  border-radius: var(--radius-md); background: var(--bg-primary); 
  color: var(--text-primary); outline: none; font-size: 1rem;
}
input:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }




/* ==========================================================================
   5. BỐ CỤC QUẢN TRỊ (PREMIUM DASHBOARD)
   ========================================================================== */
.dashboard-layout { display: flex; flex: 1; overflow: hidden; height: calc(100vh - 70px); }

/* Sidebar */
.sidebar { 
  width: 280px; background: var(--bg-secondary); padding: 30px 20px; 
  display: flex; flex-direction: column; border-right: 1px solid var(--border-color); 
}
.sidebar-menu { list-style: none; padding: 0; margin: 0; flex: 1; }
.sidebar-menu li { margin-bottom: 8px; }
.sidebar-menu a { 
  display: flex; align-items: center; gap: 12px; padding: 14px 18px; 
  color: var(--text-secondary); border-radius: var(--radius-md); 
  font-weight: 600; font-size: 0.95rem;
}
.sidebar-menu a i { font-size: 1.3rem; }
.sidebar-menu a:hover { background: var(--bg-primary); color: var(--text-primary); }
.sidebar-menu a.active { 
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%); 
  color: #ffffff; box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3); 
}
.sidebar-menu a.logout { color: #ef4444; margin-top: auto; }
.sidebar-menu a.logout:hover { background: rgba(239, 68, 68, 0.1); }

/* Nội dung Dashboard */
.main-content { flex: 1; padding: 40px 50px; overflow-y: auto; background: var(--bg-primary); }
.tab-content { display: none; animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
.tab-content.active { display: block; }
.tab-content h2 { font-size: 1.8rem; font-weight: 800; margin-bottom: 30px; display: flex; align-items: center; gap: 12px; }

/* Bảng (Table) Hiện đại */
table { 
  width: 100%; border-collapse: separate; border-spacing: 0; 
  background: var(--bg-card); box-shadow: var(--shadow-md); 
  border-radius: var(--radius-lg); overflow: hidden; 
}
th, td { padding: 18px 24px; text-align: left; }
th { 
  background: var(--bg-secondary); font-weight: 700; color: var(--text-secondary); 
  text-transform: uppercase; font-size: 0.75rem; letter-spacing: 1px; border-bottom: 1px solid var(--border-color); 
}
td { border-bottom: 1px solid var(--border-color); font-weight: 500; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-secondary); }

/* Thẻ Thống kê (Stat Cards) */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-bottom: 40px; }
.stat-card { 
  background: var(--bg-card); padding: 25px 30px; border-radius: var(--radius-lg); 
  border: 1px solid var(--border-color); box-shadow: var(--shadow-md);
  position: relative; overflow: hidden;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 4px; background: linear-gradient(to right, var(--brand-primary), var(--brand-secondary)); }
.stat-card h3 { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .value { font-size: 2.8rem; font-weight: 900; color: var(--text-primary); }

/* Ref Box (Khối mã giới thiệu) */
.ref-box { 
  background: var(--bg-card); padding: 24px 30px; border-radius: var(--radius-lg); 
  margin-bottom: 30px; border: 1px solid var(--border-color); box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: space-between;
}
.ref-text { color: var(--text-secondary); font-size: 0.9rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; display: block; margin-bottom: 5px; }
.ref-code-value { font-size: 1.8rem; font-weight: 900; background: linear-gradient(to right, var(--brand-primary), var(--brand-secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: 2px; }

/* Utilities (Badges, Texts) */
.badge { padding: 6px 12px; border-radius: 8px; font-size: 0.75rem; font-weight: 700; display: inline-flex; }
.badge-active { background: rgba(16, 185, 129, 0.15); color: var(--success-color); }
.badge-used { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.money-text { color: var(--success-color); font-weight: 800; }

@keyframes slideUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }


/* ==========================================================================
   6. MOBILE DRAWER MENU & FOOTER (CSS BỔ SUNG CHO HEADER/FOOTER COMPONENT)
   ========================================================================== */
.mobile-menu-btn { display: none; background: transparent; border: none; font-size: 2rem; cursor: pointer; color: var(--text-primary); padding: 5px; }
.mobile-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100vh; background: rgba(0,0,0,0.5); z-index: 998; opacity: 0; visibility: hidden; transition: 0.3s ease; }
.mobile-drawer { position: fixed; top: 0; left: -320px; width: 300px; height: 100vh; background: var(--bg-secondary); z-index: 999; box-shadow: 2px 0 15px rgba(0,0,0,0.1); transition: 0.3s ease; display: flex; flex-direction: column; overflow-y: auto; }
.mobile-drawer.active { left: 0; }
.mobile-overlay.active { opacity: 1; visibility: visible; }
.drawer-header { display: flex; justify-content: space-between; align-items: center; padding: 20px; border-bottom: 1px solid var(--border-color); }
.btn-close-drawer { background: var(--bg-primary); border: 1px solid var(--border-color); width: 35px; height: 35px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; cursor: pointer; color: var(--text-primary); }
.drawer-nav { display: flex; flex-direction: column; padding: 10px 20px; }
.drawer-nav a { color: var(--text-primary); font-weight: 600; font-size: 1rem; padding: 15px 0; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.drawer-controls { padding: 20px; display: flex; flex-direction: column; gap: 15px; margin-top: auto; border-top: 1px solid var(--border-color); }

/* Footer Styling */
footer { background: var(--footer-bg); color: #9ca3af; padding: 60px 0 20px; margin-top: 60px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1.5fr; gap: 30px; margin-bottom: 40px; }
.footer-grid h4 { color: white; margin-bottom: 20px; font-size: 1.1rem; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid ul li { margin-bottom: 12px; }
.footer-grid a { color: #9ca3af; transition: 0.2s; }
.footer-grid a:hover { color: white; }
.footer-bottom { border-top: 1px solid #1f2937; padding-top: 20px; display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; }

/* Responsive Media Queries cho Header & Footer */
@media (max-width: 992px) {
  .header-center, .header-right { display: none !important; }
  .mobile-menu-btn { display: block; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; gap: 15px; text-align: center; }
}