/* Mitchell Lab Interactive Tutorials — Live Editable Julia Cells & Sidebar Fixes */

/* Reliable sidebar toggles (desktop collapse + narrow slide-over drawer) */
@media (min-width: 992px) {
  html.mitchell-hide-primary-sidebar .bd-sidebar-primary,
  html.mitchell-hide-primary-sidebar #pst-primary-sidebar {
    display: none !important;
  }
}

@media (max-width: 991.98px) {
  html.mitchell-show-primary-mobile .bd-sidebar-primary,
  html.mitchell-show-primary-mobile #pst-primary-sidebar {
    display: flex !important;
    flex-direction: column !important;
    flex: none !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
    translate: 0 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: auto !important;
    bottom: 0 !important;
    margin: 0 !important;
    height: 100vh !important;
    max-height: 100vh !important;
    width: 290px !important;
    min-width: 260px !important;
    max-width: 85vw !important;
    z-index: 1060 !important;
    overflow-y: auto !important;
    pointer-events: auto !important;
    background: var(--pst-color-background, #ffffff) !important;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.28) !important;
    padding: 1rem !important;
  }
}

@media (min-width: 1200px) {
  html.mitchell-hide-secondary-sidebar .bd-sidebar-secondary,
  html.mitchell-hide-secondary-sidebar #pst-secondary-sidebar {
    display: none !important;
  }
}

@media (max-width: 1199.98px) {
  html.mitchell-show-secondary-mobile .bd-sidebar-secondary,
  html.mitchell-show-secondary-mobile #pst-secondary-sidebar {
    display: flex !important;
    flex-direction: column !important;
    flex: none !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
    translate: 0 !important;
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    left: auto !important;
    bottom: 0 !important;
    margin: 0 !important;
    height: 100vh !important;
    max-height: 100vh !important;
    width: 290px !important;
    min-width: 260px !important;
    max-width: 85vw !important;
    z-index: 1060 !important;
    overflow-y: auto !important;
    pointer-events: auto !important;
    background: var(--pst-color-background, #ffffff) !important;
    box-shadow: -4px 0 24px rgba(15, 23, 42, 0.28) !important;
    padding: 1rem !important;
  }
}

/* Dimmed backdrop behind open narrow-viewport sidebar drawers */
.mitchell-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 1055;
}

html.mitchell-show-primary-mobile .mitchell-drawer-backdrop,
html.mitchell-show-secondary-mobile .mitchell-drawer-backdrop {
  display: block;
}

/* Crisp spreadsheet-like styling for DataFrames.jl HTML outputs */
.jp-OutputArea-output table.data-frame,
.cell_output table.data-frame {
  border-collapse: collapse;
  margin: 0.5rem 0 0.85rem 0;
  font-size: 0.86rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
}

.jp-OutputArea-output table.data-frame th,
.cell_output table.data-frame th {
  background: #f1f5f9;
  color: #0f172a;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border: 1px solid #cbd5e1;
  text-align: left;
}

.jp-OutputArea-output table.data-frame td,
.cell_output table.data-frame td {
  padding: 0.3rem 0.7rem;
  border: 1px solid #e2e8f0;
}

.jp-OutputArea-output table.data-frame tbody tr:nth-child(even),
.cell_output table.data-frame tbody tr:nth-child(even) {
  background: #f8fafc;
}

/* Sticky top live-Julia toolbar */
.mitchell-live-toolbar {
  position: sticky;
  top: 3.4rem;
  z-index: 25;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin: 0 0 1.25rem 0;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  border: 1px solid #93c5fd;
  background: linear-gradient(135deg, #f8fafc 0%, #eff6ff 100%);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

html[data-theme="dark"] .mitchell-live-toolbar {
  border-color: #334155;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.mitchell-live-left,
.mitchell-live-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.mitchell-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.85rem;
  border-radius: 7px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none !important;
  transition: background-color 0.15s ease;
  border: 1px solid transparent;
}

.mitchell-btn-primary {
  background-color: #0284c7;
  color: #ffffff !important;
}

.mitchell-btn-primary:hover:not(:disabled) {
  background-color: #0369a1;
}

.mitchell-btn-primary:disabled {
  opacity: 0.7;
  cursor: wait;
}

.mitchell-btn-secondary {
  background-color: #ffffff;
  color: #1e293b !important;
  border-color: #cbd5e1;
}

.mitchell-btn-secondary:hover {
  background-color: #f1f5f9;
}

html[data-theme="dark"] .mitchell-btn-secondary {
  background-color: #1e293b;
  color: #f1f5f9 !important;
  border-color: #475569;
}

.mitchell-header-live-btn {
  background-color: #0284c7 !important;
  color: #ffffff !important;
  border-radius: 6px !important;
  font-weight: 600 !important;
  margin-right: 0.35rem;
}

.mitchell-header-live-btn:hover:not(:disabled) {
  background-color: #0369a1 !important;
}

.mitchell-header-live-btn.is-ready {
  background-color: #15803d !important;
}

.mitchell-cell-activate-pill {
  display: inline-flex;
  align-items: center;
  margin-top: 0.35rem;
  padding: 0.22rem 0.65rem;
  border-radius: 5px;
  border: 1px solid #bae6fd;
  background-color: #f0f9ff;
  color: #0369a1;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.mitchell-cell-activate-pill:hover {
  background-color: #e0f2fe;
}

html[data-theme="dark"] .mitchell-cell-activate-pill {
  background-color: #0c4a6e;
  border-color: #0284c7;
  color: #e0f2fe;
}

.mitchell-status-pill {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.mitchell-status-idle {
  background-color: #e2e8f0;
  color: #334155;
}

.mitchell-status-loading {
  background-color: #fef3c7;
  color: #92400e;
}

.mitchell-status-ready {
  background-color: #dcfce7;
  color: #166534;
}

.mitchell-status-error {
  background-color: #fee2e2;
  color: #991b1b;
}

.mitchell-status-msg {
  font-size: 0.86rem;
  color: #475569;
}

html[data-theme="dark"] .mitchell-status-msg {
  color: #cbd5e1;
}

/* Editable Thebe CodeMirror cells */
.thebe-cell {
  border: 1.5px solid #93c5fd !important;
  border-radius: 8px !important;
  margin: 0.75rem 0 !important;
  padding: 0.35rem 0.5rem 0.5rem 0.5rem !important;
  background-color: #ffffff;
}

.thebe-cell .CodeMirror {
  height: auto !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.45;
  border-radius: 6px;
}

.thebe-cell .CodeMirror-scroll {
  min-height: 2.4rem;
}

.thebe-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.thebe-button {
  padding: 0.25rem 0.65rem !important;
  border-radius: 5px !important;
  border: 1px solid #cbd5e1 !important;
  background: #f8fafc !important;
  color: #0f172a !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  cursor: pointer;
}

.thebe-button:hover {
  background: #e2e8f0 !important;
}

.thebe-run-button {
  background: #0284c7 !important;
  border-color: #0284c7 !important;
  color: #ffffff !important;
}

.thebe-run-button:hover {
  background: #0369a1 !important;
}

/* Keep SVG plots crisp and responsive */
.cell_output svg,
.jp-OutputArea-output svg {
  max-width: 100%;
  height: auto;
}
