/* Miolo WebView — visual próximo ao portal (branco + laranja), centralizado, recolhível. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

:root {
  --m2k-orange: #ea580c;
  --m2k-orange-hover: #c2410c;
  --m2k-orange-soft: #fff7ed;
  --m2k-orange-border: #fed7aa;
  --m2k-text: #1c1917;
  --m2k-muted: #57534e;
  --m2k-border: #e7e5e4;
  --m2k-bg: #f5f5f4;
  --m2k-card: #ffffff;
  --m2k-sidebar: #fafaf9;
}

.embed-body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--m2k-bg);
  color: var(--m2k-text);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
}

/* ----- Faixas horizontais: linhas → cursos ----- */
.rails {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.rail-block {
  background: var(--m2k-card);
  border: 1px solid var(--m2k-border);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 1px 3px rgba(28, 25, 23, 0.05);
}

.rail-block--cursos {
  border-left: 3px solid var(--m2k-orange);
}

.rail-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--m2k-muted);
  margin: 0 4px 8px 0;
}

/* Faixa horizontal: botões anterior / seguinte (útil em telemóvel). */
.rail-scroll-wrap {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.rail-scroll-wrap .rail-scroll {
  flex: 1;
  min-width: 0;
}

/* Setas ficam sempre visíveis; quando não há scroll, ficam disabled (não esconder — senão “somem” em ecrãs largos ou com poucas linhas). */

.rail-scroll-btn {
  flex: 0 0 auto;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  align-self: center;
  margin: 2px 0;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--m2k-border);
  background: var(--m2k-card);
  color: var(--m2k-orange-hover);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(28, 25, 23, 0.06);
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.rail-scroll-btn:hover:not(:disabled) {
  border-color: var(--m2k-orange-border);
  background: var(--m2k-orange-soft);
  color: var(--m2k-orange);
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.12);
}

.rail-scroll-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.rail-scroll-btn:disabled {
  opacity: 0.5;
  cursor: default;
  color: var(--m2k-muted);
}

.rail-scroll {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 2px 4px 4px 0;
  scroll-snap-type: x proximity;
}

.rail-scroll::-webkit-scrollbar {
  height: 6px;
}

.rail-scroll::-webkit-scrollbar-thumb {
  background: var(--m2k-border);
  border-radius: 4px;
}

.rail-chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  max-width: min(280px, 85vw);
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--m2k-border);
  background: #fafaf9;
  color: var(--m2k-text);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.rail-chip:hover {
  border-color: var(--m2k-orange-border);
  background: #fff;
}

.rail-chip.active {
  border-color: var(--m2k-orange);
  background: var(--m2k-orange-soft);
  color: var(--m2k-orange-hover);
  box-shadow: 0 0 0 1px rgba(234, 88, 12, 0.2);
}

/* ----- Conteúdo ----- */
.main {
  padding: 16px 16px 40px;
  min-width: 0;
  overflow-x: hidden;
  background: var(--m2k-bg);
}

.curso-wrap {
  max-width: 960px;
  margin: 0 auto;
}

.topbar {
  border: 1px solid var(--m2k-border);
  background: var(--m2k-card);
  border-radius: 14px;
  padding: 18px 20px 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(28, 25, 23, 0.06);
}

.topbar-title {
  margin: 0;
  font-size: clamp(1.2rem, 4vw, 1.45rem);
  font-weight: 800;
  line-height: 1.2;
  color: var(--m2k-text);
}

.topbar-sub {
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--m2k-muted);
  line-height: 1.45;
}

.status {
  margin: 8px auto 12px;
  max-width: 960px;
  font-size: 13px;
  min-height: 1.25em;
  color: var(--m2k-orange);
  font-weight: 500;
}

.container {
  margin-top: 4px;
}

/* ----- Painéis recolhíveis (região) ----- */
.fold-region {
  border: 1px solid var(--m2k-border);
  border-radius: 14px;
  background: var(--m2k-card);
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(28, 25, 23, 0.05);
}

.fold-region-summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 16px;
  background: linear-gradient(180deg, #ffffff 0%, #fafaf9 100%);
  border-bottom: 1px solid transparent;
  user-select: none;
}

.fold-region[open] > .fold-region-summary {
  border-bottom-color: var(--m2k-border);
}

.fold-region-summary::-webkit-details-marker {
  display: none;
}

.fold-region-summary-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  position: relative;
  padding-right: 28px;
}

.fold-region-summary-inner::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--m2k-orange);
  border-bottom: 2px solid var(--m2k-orange);
  transform: translateY(-60%) rotate(45deg);
  transition: transform 0.2s ease;
}

.fold-region[open] > .fold-region-summary .fold-region-summary-inner::after {
  transform: translateY(-20%) rotate(-135deg);
}

.fold-title {
  font-weight: 800;
  font-size: 15px;
  color: var(--m2k-text);
}

.fold-meta {
  font-size: 13px;
  color: var(--m2k-muted);
  font-weight: 500;
}

.fold-region-body {
  padding: 12px 14px 16px;
}

/* Capítulos internos (vídeos / apostilas) */
.fold-chapter {
  border: 1px solid var(--m2k-border);
  border-radius: 10px;
  margin-bottom: 8px;
  background: #fff;
}

.fold-chapter:last-child {
  margin-bottom: 0;
}

.fold-chapter-summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 14px;
  color: var(--m2k-text);
  background: var(--m2k-orange-soft);
  border-radius: 10px;
}

.fold-chapter[open] > .fold-chapter-summary {
  border-radius: 10px 10px 0 0;
  border-bottom: 1px solid var(--m2k-orange-border);
}

.fold-chapter-summary::-webkit-details-marker {
  display: none;
}

.fold-chapter-body {
  padding: 10px 12px 12px;
}

/* ----- Aulas (links) ----- */
.lesson {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 48px;
  padding: 12px 14px;
  margin-bottom: 6px;
  border-radius: 10px;
  background: #f8fafc;
  color: #0369a1;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--m2k-border);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.lesson:hover {
  border-color: var(--m2k-orange-border);
  background: #fff;
  color: #075985;
}

.lesson.missing {
  color: var(--m2k-muted);
  pointer-events: none;
  opacity: 0.75;
}

.lesson.lesson--vimeo-short {
  border-color: #fde68a;
  background: #fffbeb;
}

.lesson-note {
  display: block;
  font-size: 12px;
  color: var(--m2k-muted);
  margin-top: 6px;
  font-weight: 400;
  line-height: 1.4;
}

/* ----- Linhas de material (PDF + páginas) ----- */
.material-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: 10px;
  border: 1px solid var(--m2k-border);
  background: #fafafa;
}

.material-row:last-child {
  margin-bottom: 0;
}

.material-row-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--m2k-text);
  line-height: 1.35;
  flex: 1 1 200px;
  min-width: 0;
}

.material-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.material-row-err {
  font-size: 12px;
  color: #b91c1c;
}

.btn-m2k {
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 10px;
  border: none;
  background: var(--m2k-orange);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-m2k:hover {
  background: var(--m2k-orange-hover);
}

.btn-m2k-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 10px;
  border: 2px solid var(--m2k-orange);
  background: #fff;
  color: var(--m2k-orange);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-m2k-outline:hover {
  background: var(--m2k-orange-soft);
  color: var(--m2k-orange-hover);
}

.apostilas-viewer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--m2k-border);
  min-height: 12px;
}

.msg-soft {
  margin: 0;
  font-size: 14px;
  color: var(--m2k-muted);
  line-height: 1.5;
}

.galeria-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.galeria-card {
  border: 1px solid var(--m2k-border);
  border-radius: 12px;
  padding: 12px;
  background: var(--m2k-card);
}

.galeria-label {
  font-size: 12px;
  color: var(--m2k-muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.galeria-card img {
  width: 100%;
  max-width: 1100px;
  display: block;
  border-radius: 8px;
  height: auto;
}

@media (min-width: 900px) {
  .main {
    padding: 20px 28px 48px;
  }

  .rail-chip {
    max-width: 340px;
    font-size: 14px;
  }
}
