/* ==========================================================================
   ALLYNOTE — APP LAYOUT, SIDEBAR & HEADER
   ========================================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100vw;
  background-color: var(--bg-app);
  position: relative;
  overflow-x: hidden;
}

/* Sidebar (Desktop) */
.app-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  position: sticky;
  top: 0;
  left: 0;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s ease,
              background-color var(--transition-normal);
}

/* Sidebar Brand Header (Aligned with app-header) */
.sidebar-brand {
  height: var(--header-height);
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  box-sizing: border-box;
}

.brand-logo-img {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.brand-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Sidebar Navigation Items (Compact) */
.sidebar-nav {
  flex: 1;
  padding: 8px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 8px 8px 2px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.825rem;
  text-decoration: none;
  transition: all var(--transition-fast);
  position: relative;
}

.nav-item:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-item.active {
  background-color: var(--bg-active);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: none;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 5px;
  bottom: 5px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  box-shadow: none;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.nav-item:hover .nav-icon {
  color: var(--text-primary);
}

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

.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-tertiary);
  color: var(--text-secondary);
  font-weight: 600;
}

.nav-item.active .nav-badge {
  background-color: var(--primary);
  color: var(--text-inverse);
}

/* Sidebar Footer / Assistant Profile (Compact) */
.sidebar-footer {
  padding: 8px 10px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--sidebar-bg);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-tertiary);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.user-details {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.675rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Main Application Area */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

/* Top Sticky Header (Compact) */
.app-header {
  height: var(--header-height);
  background-color: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 30;
  flex-shrink: 0;
  gap: 12px;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Live Context Bar inside Header */
.header-context {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.context-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  background-color: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  max-width: 480px;
}

.context-pill:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-default);
}

.context-pill.active-lesson {
  background-color: var(--success-light);
  border-color: var(--success-border);
  color: var(--text-primary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background-color: var(--text-muted);
  flex-shrink: 0;
}

.status-dot.active {
  background-color: var(--success);
  animation: pulseGlow 2s infinite ease-in-out;
}

.status-dot.upcoming {
  background-color: var(--warning);
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.search-trigger-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 5px 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-trigger-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.kbd-shortcut {
  font-size: 0.65rem;
  font-family: var(--font-family-mono);
  background-color: var(--bg-surface-tertiary);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-weight: 600;
}

.theme-toggle-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  background-color: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  cursor: pointer;
  position: relative;
  transition: all var(--transition-normal);
  user-select: none;
}

.theme-toggle-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--primary-border);
  transform: scale(1.05);
  box-shadow: var(--shadow-sm);
}

.theme-toggle-btn:active {
  transform: scale(0.95);
}

.icon-action-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  background-color: var(--bg-surface-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-action-btn:hover {
  background-color: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-default);
}

/* Primary Header Quick Action Button */
.btn-quick-add {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--primary);
  color: #ffffff;
  padding: 5px 12px 5px 8px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--primary-border);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: none;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.btn-quick-add:hover {
  background: var(--primary-hover);
  box-shadow: none;
  transform: none;
}

.btn-quick-add:active {
  background: var(--primary);
  transform: none;
  box-shadow: none;
}

.quick-add-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
}

.btn-quick-add:hover .quick-add-plus {
  background: rgba(255, 255, 255, 0.25);
}

/* Content Container (Compact) */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px 24px 36px 24px;
  display: flex;
  flex-direction: column;
}

/* Mobile Bottom Navigation (Hidden on desktop) */
.mobile-nav-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mobile-nav-height);
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  z-index: 50;
  box-shadow: var(--shadow-sm);
  justify-content: space-around;
  align-items: center;
  padding: 0 8px;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.725rem;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

.mobile-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.mobile-fab-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  box-shadow: none;
  margin-top: -16px;
  border: 2px solid var(--bg-surface);
  transition: background var(--transition-fast);
}

.mobile-fab-btn:hover {
  background: var(--primary-hover);
  box-shadow: none;
  transform: none;
}

.mobile-fab-btn:active {
  transform: none;
}

/* Mobile Drawer Overlay */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.45);
  z-index: 9990;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.drawer-backdrop.open {
  display: block;
}

/* Guard: On desktop (>768px), drawer-backdrop must NEVER display or blur */
@media (min-width: 769px) {
  .drawer-backdrop,
  .drawer-backdrop.open {
    display: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    pointer-events: none !important;
  }

  /* Desktop collapsible sidebar */
  .app-sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
  }
}

