/* ================================================
   RESPONSIVE EDITOR — Programiz-style mobile layout
   Desktop: unchanged (side-by-side panels)
   Mobile/Tablet (<=768px): tab-switching full-screen panels
   ================================================ */

/* --- MOBILE TAB BAR (hidden on desktop) --- */
.compiler-mobile-tabs {
  display: none;
  background: #181825;
  border-bottom: 1px solid #313244;
  position: relative;
  z-index: 50;
}
.compiler-mobile-tabs .mobile-tab-row {
  display: flex;
  align-items: center;
}
.compiler-mobile-tabs .mobile-tab {
  flex: 1;
  padding: 10px 0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #6c7086;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.compiler-mobile-tabs .mobile-tab.active {
  color: #cdd6f4;
  border-bottom-color: #a6e3a1;
}
.compiler-mobile-tabs .mobile-run-btn {
  padding: 10px 20px;
  background: #a6e3a1;
  color: #1e1e2e;
  border: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.compiler-mobile-tabs .mobile-run-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.compiler-mobile-tabs .mobile-run-btn.running {
  background: #f38ba8;
}

/* --- MOBILE OVERRIDES --- */
@media (max-width: 768px) {

  /* Show the tab bar */
  .compiler-mobile-tabs {
    display: block;
  }

  /* Make wrapper fill remaining height */
  .compiler-wrapper {
    flex-direction: column !important;
    height: calc(100vh - 96px) !important;
    height: calc(100dvh - 96px) !important;
  }

  /* Editor panel — full width, hidden when output tab active */
  .editor-panel {
    flex: 1 1 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    border-right: none !important;
    border-bottom: 1px solid #313244;
    display: none !important;
  }
  .editor-panel.panel-active {
    display: flex !important;
  }

  /* Hide the resizer */
  .resizer,
  #full-resizer {
    display: none !important;
  }

  /* Terminal/output panel — full width, hidden when editor tab active */
  .terminal-panel,
  .terminal-wrapper {
    flex: 1 1 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    display: none !important;
  }
  .terminal-panel.panel-active,
  .terminal-wrapper.panel-active {
    display: flex !important;
  }

  /* Show topbar buttons on mobile, wrapped and compact — hide the run button (mobile tab bar has its own) */
  .editor-topbar .btn-group {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
  }
  .editor-topbar .btn-group .btn {
    padding: 4px 10px !important;
    font-size: 11px !important;
  }
  .editor-topbar .btn-group .btn-run,
  .editor-topbar .btn-group #btn-run {
    display: none !important;
  }

  /* Keep the desktop topbar minimal on mobile */
  .editor-topbar {
    padding: 6px 12px !important;
    min-height: 40px !important;
  }

  .terminal-topbar {
    padding: 6px 12px !important;
    min-height: 40px !important;
  }

  /* Ensure the editor and terminal fill their panels */
  #editor,
  #full-editor-pane > div[id^="full-editor"] {
    min-height: 0 !important;
  }
}

/* --- FULL EDITOR (tryit-full.ejs) MOBILE --- */
@media (max-width: 768px) {
  .full-editor-body {
    flex-direction: column !important;
  }
  #full-editor-pane {
    flex: none !important;
    width: 100% !important;
    height: 100% !important;
    border-right: none !important;
    border-bottom: 1px solid #313244;
    display: none !important;
  }
  #full-editor-pane.panel-active {
    display: block !important;
  }
  #full-output-pane {
    flex: none !important;
    width: 100% !important;
    height: 100% !important;
    display: none !important;
  }
  #full-output-pane.panel-active {
    display: flex !important;
  }

  /* Show toolbar buttons on mobile, wrapped and compact — hide run button (mobile tab bar has its own) */
  .full-editor-header .btn-group {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
  }
  .full-editor-header .btn-group button {
    padding: 4px 10px !important;
    font-size: 11px !important;
  }
  .full-editor-header .btn-group #full-run {
    display: none !important;
  }
  #full-console-panel {
    height: 40% !important;
  }
}

/* --- TRYIT EDITOR (tryit.ejs) MOBILE --- */
@media (max-width: 768px) {
  .editor-layout {
    height: 100vh !important;
    min-height: 100vh !important;
  }
  .editor-body {
    flex: 1 !important;
    flex-direction: column !important;
    height: auto !important;
    min-height: 0 !important;
  }
  /* Hide the topbar run button — mobile tab bar has its own */
  #run {
    display: none !important;
  }
  #editorPane {
    flex: 1 !important;
    min-width: 100% !important;
    min-height: 0 !important;
    border-right: none !important;
    border-bottom: 1px solid #313244;
    display: none !important;
  }
  #editorPane.panel-active {
    display: block !important;
  }
  #outputPane {
    flex: 1 !important;
    min-width: 100% !important;
    min-height: 0 !important;
    display: none !important;
  }
  #outputPane.panel-active {
    display: flex !important;
  }
  #resizer {
    display: none !important;
  }
  /* Ensure ACE editor fills its container */
  #editorPane > div {
    min-height: 0 !important;
  }
}

/* --- COMPILERS HUB (compilers.ejs) MOBILE --- */
@media (max-width: 768px) {
  .compiler-layout {
    flex-direction: column !important;
  }

  /* Hide language sidebar on mobile — show as horizontal scrollable strip */
  .lang-sidebar {
    flex-direction: row !important;
    width: 100% !important;
    height: auto !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    border-right: none !important;
    border-bottom: 1px solid #313244;
    padding: 6px 8px !important;
    gap: 6px !important;
  }

  .lang-icon {
    width: 36px !important;
    height: 36px !important;
    font-size: 11px !important;
  }

  .compiler-content {
    flex-direction: column !important;
  }

  .editor-area {
    flex: 1 1 100% !important;
    min-width: 0 !important;
    border-right: none !important;
    border-bottom: 1px solid #313244;
    display: none !important;
  }
  .editor-area.panel-active {
    display: flex !important;
  }

  .output-area {
    flex: 1 1 100% !important;
    min-width: 0 !important;
    display: none !important;
  }
  .output-area.panel-active {
    display: flex !important;
  }

  /* Hide the compiler-content resizer */
  .compiler-content .resizer {
    display: none !important;
  }

  /* Show topbar buttons on mobile, wrapped and compact — hide run button (mobile tab bar has its own) */
  .compiler-topbar .btn-group {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
  }
  .compiler-topbar .btn-group .btn {
    padding: 4px 10px !important;
    font-size: 11px !important;
  }
  .compiler-topbar .btn-group .btn-run,
  .compiler-topbar .btn-group #btn-run {
    display: none !important;
  }
}
