/* ============================================
   Mobile Layout Fix — library.sfxsai.com
   Uses body[data-qm-view] to control panels.
   "topics"  → show topics panel full-width
   "content" → show content panel full-width
   ============================================ */

@media (max-width: 767px) {

  /* ---- TOPICS VIEW: full-width topics, hide content ---- */
  body[data-qm-view="topics"] [data-qm="topics"] {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: calc(100vh - 3.5rem) !important;
    overflow-y: auto !important;
    border-right: none !important;
    flex-shrink: 0 !important;
  }

  body[data-qm-view="topics"] [data-qm="content"] {
    display: none !important;
  }

  /* ---- CONTENT VIEW: hide topics, full-width content ---- */
  body[data-qm-view="content"] [data-qm="topics"] {
    display: none !important;
  }

  body[data-qm-view="content"] [data-qm="content"] {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    flex: 1 !important;
    overflow: hidden !important;
  }

  /* ---- Back button ---- */
  #qm-back-btn {
    display: none !important;
  }

  body[data-qm-view="content"] #qm-back-btn {
    display: flex !important;
    align-items: center !important;
    gap: 6px;
    padding: 10px 16px;
    margin: 10px 12px 6px;
    background: rgba(124, 58, 237, 0.08);
    color: #7c3aed;
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Segoe UI', system-ui, sans-serif;
    cursor: pointer;
    flex-shrink: 0 !important;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
  }

  body[data-qm-view="content"] #qm-back-btn:active {
    background: rgba(124, 58, 237, 0.18) !important;
  }

  .dark body[data-qm-view="content"] #qm-back-btn,
  body.dark[data-qm-view="content"] #qm-back-btn {
    background: rgba(124, 58, 237, 0.12);
    color: #a78bfa;
    border-color: rgba(124, 58, 237, 0.3);
  }

  /* ---- Fix parent flex container ---- */
  body[data-qm-view] [data-qm="inner-flex"] {
    flex-direction: column !important;
    overflow: visible !important;
  }

  /* ---- No-course state: show helpful message ---- */
  #qm-select-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 12px;
    color: #6b7280;
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
    text-align: center;
  }

  #qm-select-prompt svg {
    opacity: 0.4;
  }
}

/* ---- Desktop: never show back button or prompt ---- */
@media (min-width: 768px) {
  #qm-back-btn,
  #qm-select-prompt {
    display: none !important;
  }
}

/* ---- Small phones ---- */
@media (max-width: 379px) {
  body[data-qm-view="content"] #qm-back-btn {
    font-size: 13px;
    padding: 8px 12px;
  }
}
