/* Course Viewer Container */
.course-viewer {
  display: flex;
  height: calc(100vh - 60px);
}

/* Left Navigation Panel */
.course-sidebar {
  width: 300px;
  background-color: #f8f9fa;
  border-right: 1px solid #dee2e6;
  overflow-y: auto;
  padding: 1rem;
  transition: transform 0.3s ease-in-out;
}

/* Main Content Area */
.course-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: white;
  position: relative;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Ensure topic pages use full width */
.course-content .topic-page {
  width: 100%;
  max-width: 100%;
  padding: 0;
  margin: 0;
}

/* Breadcrumb Container - Sticky on mobile and desktop */
.course-breadcrumb-container {
  position: sticky !important;
  top: 0 !important;
  z-index: 100 !important;
  display: flex !important;
  align-items: center;
  margin: 0;
  padding: 0;
  background-color: #ffffff !important;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  width: 100%;
  box-sizing: border-box;
}

.course-breadcrumb {
  display: flex !important;
  width: 100%;
  box-sizing: border-box;
}

/* Mobile Floating Toggle Button - Always visible on left side */
.mobile-sidebar-toggle-floating {
  display: none; /* Hidden by default, shown only on mobile */
}

@media (max-width: 768px) {
  .mobile-sidebar-toggle-floating {
    display: flex !important;
    /* Ensure it's always on top and doesn't get hidden */
    position: fixed !important;
    z-index: 1003 !important;
  }
  
  /* When sidebar is open, button moves to the right edge of sidebar */
  .course-sidebar.mobile-visible ~ .mobile-sidebar-toggle-floating,
  .course-sidebar.mobile-visible + * .mobile-sidebar-toggle-floating {
    left: 280px !important;
  }
}

/* Breadcrumb Section - Sticky on mobile */
.course-breadcrumb {
  flex: 1;
}

  /* Mobile Overlay (when sidebar is open) */
.course-viewer .mobile-overlay {
  display: none;
  position: fixed;
  /* top will be calculated dynamically - starts from header bottom */
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1001; /* Same level as breadcrumb, below sidebar */
  transition: opacity 0.3s ease-in-out;
  pointer-events: none; /* Don't block interaction when hidden */
}

.course-viewer .mobile-overlay.mobile-visible {
  pointer-events: auto; /* Allow interaction when visible */
}

/* Mobile Styles */
@media (max-width: 768px) {
  .course-viewer {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - 60px);
  }

  /* Mobile floating toggle button is always visible */
  .mobile-sidebar-toggle-floating {
    display: flex !important;
  }

  /* Make breadcrumb container fixed at bottom of header */
  .course-breadcrumb-container {
    position: fixed !important;
    /* top will be set dynamically via inline style based on actual header height */
    left: 0 !important;
    right: 0 !important;
    z-index: 1001 !important; /* Above header (1000) but below sidebar (1002) */
    background-color: #f8f9fa !important;
    border-bottom: 1px solid #dee2e6 !important;
    display: flex !important;
    align-items: stretch !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* Course content should start below breadcrumb strip */
  .course-content {
    padding-top: 0;
    margin-top: 0;
  }

  .course-breadcrumb {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
  }

  /* Mobile floating toggle button styles are inline */

  .course-sidebar {
    position: fixed;
    /* top will be calculated dynamically - starts from header bottom */
    left: 0;
    /* height will be calculated dynamically */
    width: 280px;
    max-width: 85vw;
    z-index: 1002; /* Above breadcrumb strip (1001) and content */
    transform: translateX(-100%);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
  }

  .course-viewer .course-sidebar.mobile-visible {
    transform: translateX(0);
  }

  .course-viewer .mobile-overlay.mobile-visible {
    display: block;
  }

  .course-content {
    width: 100%;
    max-width: 100vw;
    min-height: calc(100vh - 60px);
    padding-top: 0;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  /* Ensure breadcrumb container is visible on mobile and desktop */
  .course-breadcrumb-container {
    visibility: visible !important;
    opacity: 1 !important;
    display: flex !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    background-color: #ffffff !important;
  }
  
  /* Ensure breadcrumb content is visible */
  .course-breadcrumb {
    visibility: visible !important;
    opacity: 1 !important;
    display: flex !important;
    width: 100% !important;
  }
  
  /* Adjust content to start below breadcrumb strip */
  .course-content {
    margin-top: 3.5rem !important; /* Space for fixed breadcrumb strip (header 60px + breadcrumb ~50px) */
    padding-top: 0 !important;
  }
  
  /* Adjust padding for mobile content */
  .course-content > div:not(.course-breadcrumb-container) {
    padding: 1rem !important;
  }
  
  /* For topic pages, content after breadcrumb container should start below it */
  .course-content > .course-breadcrumb-container ~ * {
    margin-top: 0 !important;
  }
}

/* Desktop Styles - Ensure sidebar is always visible */
@media (min-width: 769px) {
  .course-viewer {
    flex-direction: row !important;
    height: calc(100vh - 60px) !important;
  }

  .course-sidebar {
    position: relative !important;
    transform: translateX(0) !important;
    width: 300px !important;
    height: auto !important;
    max-width: none !important;
    box-shadow: none !important;
  }

  .mobile-sidebar-toggle-floating {
    display: none !important;
  }

  /* Desktop: breadcrumb container should be relative, not fixed */
  .course-breadcrumb-container {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: auto !important;
    z-index: auto !important;
    background-color: transparent !important;
    border-bottom: none !important;
    display: flex !important;
  }
  
  /* Remove margin-top on desktop */
  .course-content {
    margin-top: 0 !important;
  }
  
  .course-content > .course-breadcrumb-container ~ * {
    margin-top: 0 !important;
  }

  .course-viewer .mobile-overlay {
    display: none !important;
  }

  .course-content {
    width: auto !important;
    max-width: 100% !important;
    min-height: auto !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  /* Restore original padding on desktop */
  .course-content > div {
    padding: 2rem !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }
}

