/* ============================================================
   LAYOUT SYSTEM — Website Học Tập Đại Học
   ============================================================ */

/* ---------- App Shell ---------- */
.app {
  display: flex;
  min-height: 100vh;
}

.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition-base);
}

.app.sidebar-collapsed .app-content {
  margin-left: var(--sidebar-collapsed);
}

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 var(--space-6);
  background: var(--bg-secondary);
  border-bottom: var(--border-thin);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.92);
}

[data-theme="dark"] .header {
  background: rgba(26, 31, 46, 0.92);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

.breadcrumb-separator {
  color: var(--text-disabled);
}

.breadcrumb a:hover {
  color: var(--text-link);
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-sidebar);
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-base), transform var(--transition-base);
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  min-height: var(--header-height);
}

.sidebar-logo-img {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: contain;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.92);
  padding: 2px;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.sidebar-brand-name {
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  white-space: nowrap;
  letter-spacing: var(--tracking-wide);
}

.sidebar-brand-sub {
  font-size: var(--text-xs);
  opacity: 0.6;
  white-space: nowrap;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: var(--space-3) 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
}

.nav-section {
  padding: var(--space-2) var(--space-4);
}

.nav-section-title {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  opacity: 0.4;
  padding: var(--space-2) var(--space-3);
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  margin: 2px 0;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: rgba(255, 255, 255, 0.95);
}

.nav-item.active {
  background: var(--bg-sidebar-active);
  color: white;
  font-weight: var(--font-semibold);
}

.nav-item-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active .nav-item-icon {
  opacity: 1;
}

.nav-item-badge {
  margin-left: auto;
  background: var(--color-accent);
  color: var(--color-neutral-0);
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  padding: 1px 8px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sidebar-user:hover {
  background: var(--bg-sidebar-hover);
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-secondary-400), var(--color-primary-500));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-bold);
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.sidebar-user-info {
  overflow: hidden;
}

.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  white-space: nowrap;
}

.sidebar-user-role {
  font-size: var(--text-xs);
  opacity: 0.5;
  white-space: nowrap;
}

/* Sidebar Toggle */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: background var(--transition-fast);
}

.sidebar-toggle:hover {
  background: var(--bg-tertiary);
}

/* Sidebar Mobile Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: calc(var(--z-sidebar) - 1);
  backdrop-filter: blur(4px);
}

/* ---------- Mobile Bottom Navigation Bar ---------- */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  height: 60px;
  align-items: stretch;
  justify-content: space-around;
  padding: 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .mobile-bottom-nav {
  background: #1A1F2E;
  border-top-color: #30363D;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  text-decoration: none;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: var(--font-medium);
  transition: color var(--transition-fast);
  position: relative;
  padding: 6px 0 4px;
}

.mobile-nav-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
}

.mobile-nav-item.active {
  color: var(--color-primary);
  font-weight: var(--font-bold);
}

.mobile-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 3px;
  background: var(--color-secondary);
  border-radius: 0 0 var(--radius-full) var(--radius-full);
}

/* ---------- Main Content ---------- */
.main {
  flex: 1;
  padding: var(--space-6) var(--space-8);
  max-width: 100%;
  overflow-x: hidden;
}

.main-narrow {
  max-width: var(--content-max-width);
  margin: 0 auto;
}

/* ---------- Page Header ---------- */
.page-header {
  margin-bottom: var(--space-8);
}

.page-title {
  font-size: var(--text-3xl);
  font-weight: var(--font-extrabold);
  margin-bottom: var(--space-2);
}

.page-subtitle {
  font-size: var(--text-md);
  color: var(--text-tertiary);
  max-width: 60ch;
}

/* ---------- Grid System ---------- */
.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto-fit {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.grid-auto-fill {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Two-column layout with TOC sidebar */
.layout-with-toc {
  display: grid;
  grid-template-columns: 1fr var(--toc-width);
  gap: var(--space-8);
  align-items: start;
}

.layout-with-toc .content-area {
  min-width: 0;
}

/* ---------- Section ---------- */
.section {
  margin-bottom: var(--space-10);
}

.section-title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.section-title::before {
  content: '';
  width: 4px;
  height: 24px;
  background: linear-gradient(180deg, var(--color-primary), var(--color-secondary));
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* ---------- Container ---------- */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* ---------- Divider ---------- */
.divider {
  border: none;
  height: 1px;
  background: var(--border-color);
  margin: var(--space-6) 0;
}

/* ---------- Table of Contents (Sticky) ---------- */
.toc {
  position: sticky;
  top: calc(var(--header-height) + var(--space-6));
  padding: var(--space-4);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: var(--border-thin);
  max-height: calc(100vh - var(--header-height) - var(--space-12));
  overflow-y: auto;
}

.toc-title {
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--text-tertiary);
  margin-bottom: var(--space-3);
}

.toc-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-item {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  padding: var(--space-1) var(--space-3);
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.toc-item:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.toc-item.active {
  color: var(--color-primary);
  border-left-color: var(--color-primary);
  font-weight: var(--font-medium);
}

.toc-item.toc-indent {
  padding-left: var(--space-6);
  font-size: var(--text-xs);
}

/* ---------- Empty State ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-8);
  text-align: center;
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  margin-bottom: var(--space-4);
  color: var(--text-disabled);
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-2);
}

.empty-state-text {
  color: var(--text-tertiary);
  max-width: 40ch;
}
