/* ========================================================
   base.css — Reset, typography, glass utilities, layout (sidebar + main shell)
   v1.5.4: tách từ style.css.
   Load thứ 2 (sau tokens.css) vì dùng CSS variables.
   ======================================================== */

/* Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, hsla(253, 70%, 15%, 0.4) 0px, transparent 50%),
    radial-gradient(at 100% 100%, hsla(190, 60%, 10%, 0.3) 0px, transparent 50%),
    radial-gradient(at 50% 50%, hsla(280, 50%, 10%, 0.15) 0px, transparent 70%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: hsla(0, 0%, 100%, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Typography elements */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Glassmorphism utility */
.glass-panel {
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  box-shadow: var(--shadow-main);
  transition: var(--transition-smooth);
}

.glass-panel:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.glow-purple:hover {
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37), var(--shadow-neon-primary);
  border-color: var(--primary-glow);
}

.glow-cyan:hover {
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37), var(--shadow-neon-secondary);
  border-color: var(--border-cyan);
}

/* Layout Framework */
.app-container {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* Sidebar Styles */
.sidebar {
  background: hsla(222, 24%, 10%, 0.85);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-light);
  padding: 24px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  position: relative;
}

/* P3.8 — sidebar collapse: nút toggle ở góc brand (chevron) */
.sidebar-toggle {
  margin-left: auto;
  background: hsla(0, 0%, 100%, 0.04);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  width: 28px; height: 28px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  transition: var(--transition-smooth);
  flex: none;
}
.sidebar-toggle:hover { background: hsla(250, 85%, 65%, 0.18); color: var(--text-primary); border-color: var(--primary); }

/* Collapsed state: chỉ icon — width 72px, ẩn label + section title + client list */
.app-container.sidebar-collapsed { grid-template-columns: 72px 1fr; }
.sidebar-collapsed .sidebar { padding: 16px 8px; }
.sidebar-collapsed .brand { justify-content: center; margin-bottom: 24px; }
.sidebar-collapsed .brand-name { display: none; }
.sidebar-collapsed .sidebar-toggle { margin-left: 0; position: absolute; top: -2px; right: -34px; }
.sidebar-collapsed .sidebar-toggle i { transform: rotate(180deg); }
.sidebar-collapsed .nav-section-title { display: none; }
.sidebar-collapsed .nav-item { justify-content: center; padding: 12px 0; gap: 0; }
.sidebar-collapsed .nav-item span { display: none; }
.sidebar-collapsed .nav-item:hover, .sidebar-collapsed .nav-item.active { padding-left: 0; border-left: none; }
.sidebar-collapsed .client-list-sidebar { display: none; }

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  font-weight: 800;
  box-shadow: var(--shadow-neon-primary);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, #fff, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 700;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.nav-item i {
  font-size: 18px;
  width: 20px;
  text-align: center;
}

.nav-item:hover, .nav-item.active {
  color: var(--text-primary);
  background: hsla(250, 85%, 65%, 0.15);
  border-left: 3px solid var(--primary);
  padding-left: 13px;
}

.nav-item.active i {
  color: var(--secondary);
  filter: drop-shadow(0 0 5px var(--secondary-glow));
}

.client-list-sidebar {
  flex-grow: 1;
  overflow-y: auto;
  margin-top: 16px;
}

.sidebar-client-card {
  padding: 10px 12px;
  border-radius: 8px;
  background: hsla(0, 0%, 100%, 0.03);
  border: 1px solid var(--border-light);
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.sidebar-client-card:hover {
  background: hsla(0, 0%, 100%, 0.07);
}

.sidebar-client-card.active {
  border-color: var(--primary-glow);
  background: hsla(250, 85%, 65%, 0.08);
}

.sidebar-client-name {
  font-size: 13px;
  font-weight: 600;
}

.sidebar-client-niche {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main Content Area */
.main-content {
  padding: 40px;
  overflow-y: auto;
  height: 100vh;
}

/* ========================================================
   Responsive (v1.5.6) — đặt ở CUỐI file để override base rules.
   < 900px (tablet): stack sidebar lên trên, main full width.
   < 600px (mobile): sidebar gọn lại, ẩn list client phụ.
   Hamburger drawer đầy đủ → Phase 3.
   ======================================================== */
@media (max-width: 900px) {
  .app-container {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto; /* không stretch 100vh */
    border-right: none;
    border-bottom: 1px solid var(--border-light);
    padding: 16px;
  }
  .main-content {
    height: auto;
    padding: 24px 16px;
  }
}

@media (max-width: 600px) {
  .sidebar {
    padding: 12px 16px;
  }
  /* Ẩn section "Khách Hàng" (heading thứ 2) + list client để gọn */
  .sidebar .nav-section-title:nth-of-type(2),
  .sidebar .client-list-sidebar {
    display: none;
  }
  /* Menu chính chuyển sang horizontal scroll */
  .sidebar .nav-menu {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
  }
  .sidebar .nav-menu li {
    flex-shrink: 0;
  }
  .sidebar .nav-item span {
    white-space: nowrap;
  }
  /* Reduce title size cho mobile */
  .page-title h1 {
    font-size: 1.5rem;
  }
}
