/* Layout structure */
#app-layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Sidebar logo area */
.logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}


/* Sidebar */
.sidebar {
  width: 220px;
  background-color: var(--surf);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand {
  padding: 32px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.logo-ic {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  width: 38px;
  height: 38px;
  border-radius: var(--rad-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-family: var(--font-display);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-text h1 {
  font-size: 16px;
  color: #fff;
}

.brand-text span {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-sans);
}

.nav-links {
  flex: 1;
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.nav-btn {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: var(--rad-md);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 13px;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  cursor: pointer;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.nav-btn.active {
  background: rgba(92, 107, 192, 0.15);
  color: var(--primary);
  border-color: rgba(92, 107, 192, 0.3);
}

.nav-footer {
  padding: 20px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-color);
  position: relative;
}

/* Top Header */
.top-header {
  height: 80px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surf-glass);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.header-left h2 {
  font-size: 22px;
  color: #fff;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.exam-countdown {
  background: rgba(255, 167, 38, 0.1);
  border: 1px solid rgba(255, 167, 38, 0.2);
  padding: 6px 14px;
  border-radius: var(--rad-round);
  font-size: 12px;
  color: var(--warning);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.exam-countdown .days {
  font-size: 16px;
  font-family: var(--font-display);
  font-weight: 800;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--rad-round);
  transition: background 0.2s;
}

.user-profile:hover {
  background: rgba(255, 255, 255, 0.05);
}

.avatar {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  font-family: var(--font-display);
}

.user-profile .name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: none;
}

/* View Root Area */
#app-root,
#auth-root {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 32px;
  position: relative;
}

/* Ensure chart canvases and interactive graphics do not trap mobile touch scrolling */
canvas {
  touch-action: pan-y;
}

/* Toast System Layout */
.toast-container {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

/* Responsive Handling */
@media (min-width: 1024px) {
  .user-profile .name {
    display: block;
  }
}

@media (max-width: 1024px) {
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 260px !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 101 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.4) !important;
  }

  .sidebar.mobile-open {
    transform: translateX(0) !important;
  }

  /* Force show elements inside the mobile drawer */
  .brand-text,
  .nav-btn span,
  .nav-footer,
  #sidebar-footer,
  .sidebar #sidebar-logo-text,
  .sidebar .nav-txt,
  .sidebar #sb-username {
    display: flex !important;
  }

  .sidebar-profile {
    display: flex !important;
    padding: 8px !important;
    border-radius: var(--rad-sm) !important;
    background: var(--surf-elevated) !important;
  }

  .nav-btn {
    justify-content: flex-start !important;
    padding: 12px 16px !important;
  }

  .nav-btn span.icon {
    display: inline !important;
  }

  .nav-btn .nav-txt {
    display: inline-block !important;
    margin-left: 8px;
  }

  .logo button.i-btn {
    display: none !important;
  }

  #sidebar-resizer {
    display: none !important;
  }

  .top-header {
    padding: 0 16px;
  }

  #app-root {
    padding: 16px !important;
  }

  /* Hamburger and Header adjustments */
  #mobile-nav-toggle {
    display: block !important;
  }

  #page-title {
    display: block !important;
    font-size: 18px !important;
    font-weight: 800 !important;
    color: var(--text-primary) !important;
    margin: 0 !important;
  }

  #header-date {
    display: none !important;
  }

  /* Sidebar Backdrop overlay */
  #sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
  }
}

@media (max-width: 480px) {
  #nov-countdown {
    display: none !important;
  }
}

/* Sidebar Compact Mode Styles (Desktop only) */
@media (min-width: 1025px) {
  .sidebar.compact-mode #sidebar-logo-text,
  .sidebar.compact-mode .nav-txt,
  .sidebar.compact-mode #sb-username {
    display: none !important;
  }

  .sidebar.compact-mode .nav-btn {
    justify-content: center !important;
    padding: 12px 0 !important;
  }

  .sidebar.compact-mode .sidebar-profile {
    justify-content: center !important;
    padding: 8px 0 !important;
    background: transparent !important;
  }

  .sidebar.compact-mode .i-btn {
    margin: 0 auto !important;
  }

  /* Ensure icons remain centered properly */
  .sidebar.compact-mode .icon {
    margin-right: 0 !important;
  }
}

/* User Guide Page Layout */
.guide-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.guide-sidebar {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

@media (max-width: 768px) {
  .guide-layout {
    flex-direction: column;
    align-items: stretch;
  }
  .guide-sidebar {
    width: 100% !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    padding-bottom: 8px !important;
    -webkit-overflow-scrolling: touch !important;
    flex-wrap: nowrap !important;
  }
  .guide-sidebar button {
    flex-shrink: 0 !important;
    width: auto !important;
  }
  .guide-shortcuts-card {
    display: none !important; /* Hide keyboard shortcut side card on mobile to save space */
  }
}