/* ==========================================================================
   NAIS AIS2 Client Layout & Navigation Architecture
   Desktop Sidebar + Mobile Bottom Tabbar + Glass Drawer & Modal
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: -1;
  pointer-events: none;
}

.app-wrapper {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 10;
}

/* ==========================================================================
   Desktop Sidebar
   ========================================================================== */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: sticky;
  top: 0;
  background: rgba(8, 12, 32, 0.65);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-right: 1px solid var(--border-subtle);
  padding: 24px 16px;
  z-index: 50;
  transition: transform 0.3s ease;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 24px 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.brand-logo-box {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 0 20px var(--primary-glow);
}

.brand-logo-box img {
  width: 100%;
  height: 100%;
  display: block;
}

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

.brand-name {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #ffffff;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
  color: #ffffff;
  background: rgba(99, 102, 241, 0.16);
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.15), 0 4px 15px rgba(99, 102, 241, 0.2);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 10px var(--primary);
}

.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
}

.student-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
}

.student-meta {
  flex: 1;
  overflow: hidden;
}

.student-name {
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.student-status {
  font-size: 0.72rem;
  color: var(--accent-emerald);
}

/* ==========================================================================
   Main Content Layout
   ========================================================================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-bottom: 80px; /* Space for mobile tabbar */
}

@media (min-width: 901px) {
  .main-content {
    padding-bottom: 40px;
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: rgba(8, 12, 32, 0.45);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-trigger-btn {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(139, 92, 246, 0.25) 100%);
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #e0e7ff;
}

.ai-trigger-btn:hover {
  border-color: rgba(139, 92, 246, 0.7);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.35);
}

.view-container {
  padding: 28px;
  flex: 1;
  animation: viewFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Mobile Bottom Tab Bar (< 900px)
   ========================================================================== */
.mobile-tabbar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(8, 12, 30, 0.85);
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  border-top: 1px solid var(--border-subtle);
  z-index: 100;
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px)) 6px;
  justify-content: space-around;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
}

.mobile-tabbar::-webkit-scrollbar {
  display: none;
}

.mobile-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.62rem;
  font-weight: 500;
  flex: 1;
  min-width: 44px;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  cursor: pointer;
  white-space: nowrap;
}

.mobile-tab-btn svg {
  width: 20px;
  height: 20px;
}

.mobile-tab-btn.active {
  color: var(--primary);
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }
  .mobile-tabbar {
    display: flex;
  }
  .topbar {
    padding: 12px 16px;
  }
  .view-container {
    padding: 16px;
  }
}

/* ==========================================================================
   Jarvis AI Slide-over Drawer
   ========================================================================== */
.ai-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.ai-drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.ai-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 92vw);
  background: rgba(11, 15, 36, 0.88);
  backdrop-filter: blur(32px) saturate(190%);
  -webkit-backdrop-filter: blur(32px) saturate(190%);
  border-left: 1px solid var(--border-subtle);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.7);
  z-index: 210;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
}

.drawer-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}

.drawer-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-bubble {
  max-width: 86%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 20px;
}

.chip-btn {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #c7d2fe;
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip-btn:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: rgba(99, 102, 241, 0.55);
}

.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(12px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: min(640px, 95vw);
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px;
  border-radius: var(--radius-xl);
}

/* ==========================================================================
   Authentication Screen Styles (Liquid Glass Auth)
   ========================================================================== */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 22, 0.82);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  padding: 20px;
  overflow-y: auto;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 32px 28px;
  text-align: center;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-top: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.7), 0 0 50px rgba(99, 102, 241, 0.15);
  background: rgba(13, 18, 44, 0.75);
}

.auth-header {
  margin-bottom: 22px;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 20px;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.auth-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-tab.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.auth-code-input {
  width: 100%;
  text-align: center;
  font-size: 1.6rem;
  letter-spacing: 5px;
  font-weight: 700;
  padding: 12px;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.auth-submit-btn {
  width: 100%;
  padding: 13px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 12px;
  margin-top: 6px;
  cursor: pointer;
}

.auth-bot-helper {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-security-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.76rem;
  color: #a7f3d0;
  margin-bottom: 14px;
}

.auth-demo-divider {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-demo-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: color 0.2s ease;
}

.btn-demo-link:hover {
  color: #fff;
}

.auth-error-alert {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.84rem;
  margin-bottom: 14px;
  text-align: left;
}
