/* ============================================
   CPP LIBRARY - Menu ngang/dọc responsive
   Topbar + Dropdown + Sidebar (hamburger mobile)
   ============================================ */

/* === TOPBAR === */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem 0 1.25rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(12px);
}

body.theme-dark .topbar {
  background: rgba(28, 33, 40, 0.95);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  min-width: 0;
  overflow: visible;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Brand */
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.topbar .brand:hover { text-decoration: none; color: inherit; }

.topbar .brand-logo-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 6px;
}

.topbar .brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.topbar .brand-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar .brand-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.topbar .brand-title span { color: var(--accent-cpp); }

/* Brand short: bỏ tagline ở trang con (chỉ icon + CPP Library) */
.topbar .brand-short .brand-sub { display: none; }

/* Search trong topbar */
.topbar .search-container {
  flex: 1;
  max-width: 320px;
  margin: 0 0.5rem;
}

/* === MENU NGANG (Horizontal) === */
.horizontal-menu {
  flex: 1;
  min-width: 0;
  margin-left: 0.5rem;
  display: flex;
  align-items: center;
  overflow: visible;
}

.horizontal-menu .menu-container {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: max-content;
  height: 100%;
  overflow: visible;
}

.horizontal-menu .nav-link {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  white-space: nowrap;
  transition: all var(--transition);
}

.horizontal-menu .nav-link:hover,
.horizontal-menu .nav-link.active {
  color: var(--accent-cpp);
  background: rgba(14, 165, 233, 0.08);
}

body.theme-dark .horizontal-menu .nav-link:hover,
body.theme-dark .horizontal-menu .nav-link.active {
  background: rgba(121, 192, 255, 0.1);
}

/* === DROPDOWN === */
.menu-dropdown {
  position: relative;
  display: inline-block;
  overflow: visible;
}

.menu-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  white-space: nowrap;
  transition: all var(--transition);
}

.menu-dropdown-toggle:hover {
  color: var(--accent-cpp);
  background: rgba(14, 165, 233, 0.08);
}

.menu-dropdown-arrow {
  font-size: 0.65rem;
  margin-left: 0.2rem;
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.menu-dropdown.open .menu-dropdown-arrow {
  transform: rotate(180deg);
}

.menu-dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-strong);
  z-index: 10001;
  overflow: hidden;
  padding: 0.25rem;
}

.menu-dropdown.open .menu-dropdown-content {
  display: block;
}

.menu-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.15s ease;
  border-radius: 6px;
}

.menu-dropdown-item:hover,
.menu-dropdown-item.active {
  background: var(--bg-tertiary);
  color: var(--accent-cpp);
  text-decoration: none;
}

.menu-dropdown-item i {
  width: 18px;
  text-align: center;
  color: var(--accent-cpp);
  font-size: 0.9rem;
}

/* Nút icon topbar */
.topbar .btn-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}

.topbar .btn-icon:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-cpp);
  color: var(--accent-cpp);
}

.topbar .sidebar-toggle {
  display: none;
}

/* === SIDEBAR (Mobile) === */
.cpp-sidebar {
  display: none;
  position: fixed;
  left: -280px;
  top: 56px;
  width: 260px;
  height: calc(100vh - 56px);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-strong);
  z-index: 1001;
  transition: left 0.3s ease;
  overflow-y: auto;
}

body.sidebar-open .cpp-sidebar {
  left: 0;
}

.cpp-sidebar-inner {
  padding: 1rem 0.75rem;
}

.cpp-sidebar .search-container {
  padding: 0 0.75rem 1rem;
  margin: 0;
  max-width: none;
}

.cpp-sidebar .search-input {
  width: 100%;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.9rem;
  border-radius: var(--radius);
  transition: all 0.15s ease;
}

.sidebar-nav .nav-link:hover {
  background: var(--bg-tertiary);
  color: var(--accent-cpp);
  text-decoration: none;
}

.sidebar-nav .nav-link i {
  width: 22px;
  text-align: center;
  color: var(--accent-cpp);
}

/* Sidebar dropdown */
.sidebar-nav .menu-dropdown {
  display: block;
}

.sidebar-nav .menu-dropdown-toggle {
  width: 100%;
  justify-content: flex-start;
  padding: 0.75rem 1rem;
  text-align: left;
}

.sidebar-nav .menu-dropdown-content {
  position: static;
  box-shadow: none;
  border: none;
  margin: 0.25rem 0 0.5rem 1.5rem;
  padding: 0.25rem 0;
  border-left: 2px solid var(--border);
  padding-left: 1rem;
  display: none;
}

.sidebar-nav .menu-dropdown.open .menu-dropdown-content {
  display: block;
}

.sidebar-nav .menu-dropdown-item {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

/* Phần menu Quản lý trong sidebar (admin) */
.sidebar-admin-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.sidebar-admin-section .sidebar-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 1rem 0.5rem;
  margin-bottom: 0.25rem;
}
.sidebar-admin-section .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
}
.sidebar-admin-section .nav-link .badge {
  margin-left: auto;
  background: rgba(14, 165, 233, 0.2);
  color: var(--accent-cpp);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
}
.sidebar-admin-section .nav-link.active .badge {
  background: rgba(255, 255, 255, 0.3);
}

.sidebar-admin-section .menu-dropdown {
  display: block;
}
.sidebar-admin-section .menu-dropdown-toggle {
  width: 100%;
  justify-content: flex-start;
  padding: 0.75rem 1rem;
  text-align: left;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.sidebar-admin-section .menu-dropdown-content {
  position: static;
  box-shadow: none;
  border: none;
  margin: 0.25rem 0 0.5rem 1.5rem;
  padding: 0.25rem 0;
  border-left: 2px solid var(--border);
  padding-left: 1rem;
  display: none;
}
.sidebar-admin-section .menu-dropdown.open .menu-dropdown-content {
  display: block;
}
.sidebar-admin-section .menu-dropdown-item {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.sidebar-admin-section .menu-dropdown.active .menu-dropdown-toggle {
  color: var(--accent-cpp);
}

/* Giao diện sáng: tăng tương phản menu sidebar (dễ nhìn trên nền trắng) */
body:not(.theme-dark):not([data-theme="dark"]) .cpp-sidebar .sidebar-nav .nav-link,
body:not(.theme-dark):not([data-theme="dark"]) .cpp-sidebar .sidebar-nav .menu-dropdown-toggle,
body:not(.theme-dark):not([data-theme="dark"]) .cpp-sidebar .sidebar-admin-section .nav-link {
  color: #1e293b;
}
body:not(.theme-dark):not([data-theme="dark"]) .cpp-sidebar .sidebar-admin-section .sidebar-section-title {
  color: #475569;
}
body:not(.theme-dark):not([data-theme="dark"]) .cpp-sidebar .sidebar-nav .nav-link i,
body:not(.theme-dark):not([data-theme="dark"]) .cpp-sidebar .sidebar-nav .menu-dropdown-toggle i {
  color: #0ea5e9;
}
body:not(.theme-dark):not([data-theme="dark"]) .cpp-sidebar .sidebar-admin-section .nav-link:not(.active) i {
  color: #64748b;
}
body:not(.theme-dark):not([data-theme="dark"]) .cpp-sidebar .sidebar-admin-section .menu-dropdown-toggle {
  color: #1e293b;
}
body:not(.theme-dark):not([data-theme="dark"]) .cpp-sidebar .sidebar-admin-section .menu-dropdown-toggle i {
  color: #0ea5e9;
}
body:not(.theme-dark):not([data-theme="dark"]) .cpp-sidebar {
  background: #ffffff;
  border-right-color: #e2e8f0;
}

/* === BACKDROP === */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 56px 0 0 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  backdrop-filter: blur(2px);
}

body.sidebar-open .sidebar-backdrop {
  display: block;
}

/* === RESPONSIVE: Hamburger + Sidebar === */
@media (max-width: 900px) {
  .horizontal-menu {
    display: none !important;
  }

  .topbar .sidebar-toggle {
    display: inline-flex !important;
  }

  .cpp-sidebar {
    display: block;
  }

  .topbar .search-container {
    max-width: 180px;
  }
}

@media (max-width: 600px) {
  .topbar .search-container {
    display: none;
  }

  .cpp-sidebar .search-container {
    display: block;
  }
}
