/* responsive.css - mobile-first responsive overrides */
@media only screen and (max-width: 768px) {

  /* Force layout containers to stack vertically */
  .dashboard-container,
  .dashboard-wrapper,
  .pme-dashboard,
  .main-dashboard {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
  }

  /* Hide common sidebar selectors by default */
  .sidebar,
  .left-panel,
  .dashboard-sidebar {
    display: none !important;
    width: 100% !important;
  }

  /* Show when toggle button clicked (add .show via JS or toggle class) */
  .sidebar.show,
  .left-panel.show,
  .dashboard-sidebar.show {
    display: block !important;
    background: #fff;
    position: relative;
    z-index: 1000;
  }

  /* Main content full width */
  .main-content,
  .right-panel,
  .dashboard-main {
    width: 100% !important;
    padding: 10px !important;
  }

  /* Stack dashboard cards vertically */
  .dashboard-card,
  .pme-card {
    width: 100% !important;
    margin-bottom: 15px !important;
  }

  /* Prevent horizontal overflow and allow vertical scroll */
  html, body {
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

 
}




/* =========================================
   📱 Mobile Responsive Fix
   ========================================= */

@media (max-width: 768px) {
  /* Stack everything vertically */
  main#site-content {
    flex-direction: column;
  }

  /* Sidebar - full width, hidden by default */
  .sidebar {
    display: none;
    width: 100%;
    height: auto;
    overflow-y: auto;
    background: #fff;
    z-index: 50;
  }

  /* Show sidebar when toggled */
  .sidebar.show {
    display: block;
  }

  /* Sidebar toggle button */
  .sidebar-toggle {
    display: block;
    background: #2563eb;
    color: white;
    padding: 0.75rem 1.25rem;
    text-align: center;
    font-weight: 600;
    border-radius: 0.5rem;
    margin: 1rem;
  }

  /* Hide sidebar toggle on desktop */
  @media (min-width: 769px) {
    .sidebar-toggle {
      display: none;
    }
  }

  /* Make all sidebars and sections take full width */
  aside,
  section {
    width: 100% !important;
    max-width: 100%;
    padding: 1rem;
  }

  /* Ensure scrolling works on mobile */
  body,
  html {
    overflow-x: hidden;
  }

  /* Make cards scrollable vertically */
  .flex,
  .grid,
  .space-y-2,
  .space-y-4 {
    overflow-x: hidden;
    overflow-y: auto;
  }

  /* Adjust header for smaller screens */
  header {
    flex-wrap: wrap;
    text-align: center;
    justify-content: center;
  }

  header .flex.items-center.space-x-6 {
    flex-wrap: wrap;
    justify-content: center;
  }
}





/* =========================================
   📱 Fix: Popup layout for mobile
   ========================================= */
@media (max-width: 768px) {
  .pme-popup,
  .topics-popup,
  .subjects-popup {
    width: 90% !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    max-height: 80vh !important;
    overflow-y: auto !important;
    border-radius: 0.75rem !important;
  }

  /* Optional: If popup slides in using transition */
  .pme-popup.slide-in,
  .topics-popup.slide-in,
  .subjects-popup.slide-in {
    animation: slideInMobile 0.3s ease-out forwards !important;
  }

  @keyframes slideInMobile {
    from {
      transform: translate(-50%, -60%) scale(0.95);
      opacity: 0;
    }
    to {
      transform: translate(-50%, -50%) scale(1);
      opacity: 1;
    }
  }
}




/* =========================================
   📱 Fix Topic Popup Position on Mobile
   ========================================= */
@media (max-width: 768px) {
  #topicPopup {
    position: fixed !important;
    top: 20% !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: 90% !important;
    max-width: 400px !important;
    height: auto !important;
    max-height: 70vh !important;
    background: #fff !important;
    border-radius: 1rem !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    z-index: 9999 !important;
  }

  /* Optional: Adjust header inside popup */
  #topicPopup > div:first-child {
    position: sticky;
    top: 0;
    background: #fef9c3; /* same yellow-100 */
    z-index: 2;
  }
}







/* =========================================
   📱 Fix close button not clickable on mobile
   ========================================= */
@media (max-width: 768px) {
  #topicPopup #closePopup {
    position: absolute !important;
    top: 0.75rem !important;
    right: 0.75rem !important;
    z-index: 10000 !important;
    font-size: 2rem !important;
    background: none !important;
    border: none !important;
    cursor: pointer !important;
    pointer-events: auto !important;
  }

  /* Make sure popup content doesn’t block touches */
  #topicPopup {
    pointer-events: auto !important;
  }

  /* If something overlays the popup (rare case) */
  .modal-backdrop,
  .overlay,
  .fixed.inset-0 {
    z-index: 10 !important;
  }
}





@media (max-width: 768px) {
  #topicPopup #closePopup {
    z-index: 10000 !important;
    pointer-events: auto !important;
    position: absolute !important;
    right: 1rem !important;
    top: 0.75rem !important;
  }
}






/* =========================================
   📱 Fix cropped buttons in 'Currently Studying' list
   ========================================= */
@media (max-width: 768px) {

  /* Target each topic row */
  #studyingList li,
  #finishedList li {
    flex-direction: column !important;   /* stack text + buttons vertically */
    align-items: flex-start !important;  /* align nicely to the left */
    gap: 0.5rem !important;
    padding: 0.75rem !important;
    overflow: visible !important;
  }

  /* Topic text should take full width */
  #studyingList .topic-text {
    width: 100% !important;
    white-space: normal !important;
    word-break: break-word !important;
  }

  /* Buttons stack horizontally but wrap if needed */
  #studyingList .flex-shrink-0 {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
    width: 100% !important;
    justify-content: flex-start !important;
  }

  /* Buttons themselves resize gracefully */
  #studyingList button {
    flex: 1 1 45% !important;
    text-align: center;
    font-size: 0.9rem !important;
    padding: 0.5rem !important;
  }
}




/* =========================================
   📱 Hide calendar button on mobile
   ========================================= */
@media (max-width: 768px) {
  #openCalendarBtn,
  .open-calendar-btn,
  .calendar-open-btn {
    display: none !important;
  }
}
