/* =====================
   App Header
   ===================== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--color-sidebar-bg);
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-4);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.header-logo-icon {
  width: 32px;
  height: 32px;
  background: var(--color-primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.header-logo-text {
  font-size: var(--text-base);
  font-weight: var(--font-bold);
  color: #FFFFFF;
  white-space: nowrap;
}

.header-divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.12);
  flex-shrink: 0;
}

.header-chapter-info {
  flex: 1;
  min-width: 0;
}

.header-chapter-label {
  font-size: var(--text-xs);
  color: var(--color-sidebar-muted);
  font-weight: var(--font-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1px;
}

.header-chapter-title {
  font-size: var(--text-sm);
  color: var(--color-sidebar-text);
  font-weight: var(--font-semibold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.header-progress-bar-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.header-progress-label {
  font-size: var(--text-xs);
  color: var(--color-sidebar-muted);
  white-space: nowrap;
}

.header-progress-bar {
  width: 100px;
  height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.header-progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.header-progress-percent {
  font-size: var(--text-xs);
  color: #FFFFFF;
  font-weight: var(--font-semibold);
  min-width: 28px;
  text-align: right;
}

.header-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--color-sidebar-text);
  transition: background var(--transition-fast);
}

.header-menu-btn:hover {
  background: rgba(255,255,255,0.08);
}

/* =====================
   App Wrapper
   ===================== */
.app-wrapper {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height) - var(--footer-height));
}

/* =====================
   Sidebar
   ===================== */
.app-sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: var(--footer-height);
  width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: var(--z-sidebar);
  border-right: 1px solid rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
}

.app-sidebar::-webkit-scrollbar {
  width: 4px;
}
.app-sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.app-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
}

.sidebar-header {
  padding: var(--space-5) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--color-sidebar-border);
}

.sidebar-progress-label {
  font-size: var(--text-xs);
  color: var(--color-sidebar-muted);
  font-weight: var(--font-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.sidebar-progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-2);
}

.sidebar-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), #60A5FA);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.sidebar-progress-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-progress-count {
  font-size: var(--text-xs);
  color: var(--color-sidebar-muted);
}

.sidebar-progress-percent {
  font-size: var(--text-xs);
  color: var(--color-primary);
  font-weight: var(--font-semibold);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3) 0;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background var(--transition-fast);
  position: relative;
  border-radius: 0;
}

.sidebar-nav-item:hover {
  background: var(--color-sidebar-hover);
}

.sidebar-nav-item.active {
  background: rgba(37, 99, 235, 0.15);
}

.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--color-primary);
  border-radius: 0 2px 2px 0;
}

.sidebar-nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.sidebar-nav-icon.status-completed {
  color: var(--color-success);
}

.sidebar-nav-icon.status-active {
  color: var(--color-primary);
}

.sidebar-nav-icon.status-pending {
  color: var(--color-sidebar-muted);
}

.sidebar-nav-content {
  flex: 1;
  min-width: 0;
}

.sidebar-nav-chapter-num {
  font-size: var(--text-xs);
  color: var(--color-sidebar-muted);
  margin-bottom: 1px;
}

.sidebar-nav-title {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav-item.active .sidebar-nav-title {
  color: var(--color-sidebar-text-active);
  font-weight: var(--font-semibold);
}

.sidebar-nav-item:not(.active) .sidebar-nav-title {
  color: var(--color-sidebar-text);
}

.sidebar-nav-item.completed .sidebar-nav-title {
  color: rgba(203,213,225,0.7);
}

.sidebar-nav-time {
  font-size: var(--text-xs);
  color: var(--color-sidebar-muted);
  flex-shrink: 0;
}

/* =====================
   Main Content
   ===================== */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  margin-right: var(--right-panel-width);
  padding: var(--space-8) var(--space-8) var(--space-16);
  min-height: calc(100vh - var(--header-height) - var(--footer-height));
}

/* =====================
   Right Panel
   ===================== */
.app-right-panel {
  position: fixed;
  top: var(--header-height);
  right: 0;
  bottom: var(--footer-height);
  width: var(--right-panel-width);
  background: var(--color-bg-white);
  border-left: 1px solid var(--color-border);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.app-right-panel::-webkit-scrollbar {
  width: 4px;
}
.app-right-panel::-webkit-scrollbar-track {
  background: transparent;
}
.app-right-panel::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 2px;
}

.right-panel-section {
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.right-panel-section:last-child {
  border-bottom: none;
}

.right-panel-section-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-3);
}

/* =====================
   Footer
   ===================== */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--footer-height);
  background: var(--color-bg-white);
  border-top: 1px solid var(--color-border);
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  padding: 0 var(--space-8);
  margin-left: var(--sidebar-width);
  gap: var(--space-4);
}

.footer-nav-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  transition: all var(--transition-fast);
  border: 2px solid transparent;
}

.footer-nav-btn.prev-btn {
  color: var(--color-text-secondary);
  border-color: var(--color-border);
  background: var(--color-bg-white);
}

.footer-nav-btn.prev-btn:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.footer-nav-btn.next-btn {
  background: var(--color-primary);
  color: white;
  margin-left: auto;
}

.footer-nav-btn.next-btn:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.footer-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.footer-chapter-dots {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
}

.footer-chapter-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-border);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.footer-chapter-dot.active {
  background: var(--color-primary);
  width: 20px;
}

.footer-chapter-dot.completed {
  background: var(--color-success);
}

/* =====================
   Sidebar Overlay (Mobile)
   ===================== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: calc(var(--z-sidebar) - 1);
}

.sidebar-overlay.visible {
  display: block;
}
