/* ============================================================
   LAYOUT — App Shell
   ============================================================ */

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

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-system);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- App container fullscreen ---- */
.app-shell {
  width: 100vw;
  height: 100dvh;
  display: flex;
  overflow: hidden;
  background: var(--bg-color);
  position: relative;
  isolation: isolate;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: 256px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--z-sidebar);
  transition: transform 0.3s var(--ease-smooth);
}

/* Sidebar header */
.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--sidebar-logo-bg);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-text-strong);
  font-size: 17px;
}

.sidebar-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--sidebar-text-strong);
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  padding: 8px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--sidebar-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 10px;
  margin-bottom: 4px;
  margin-top: 18px;
}

.nav-section:first-child .nav-section-title {
  margin-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--sidebar-text);
  cursor: pointer;
  user-select: none;
  transition: background 0.1s ease, color 0.1s ease;
  text-decoration: none;
  position: relative;
}

/* trilho luminoso do item ativo */
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.6);
}

.nav-item:hover {
  background: var(--sidebar-item-hover-bg);
  color: var(--sidebar-item-hover-text);
}

.nav-item.active {
  background: var(--sidebar-item-active-bg);
  color: var(--sidebar-item-active-text);
  font-weight: 500;
}

.nav-item.active svg {
  opacity: 1;
}

.nav-item svg {
  opacity: 0.6;
  flex-shrink: 0;
}

.nav-item:hover svg {
  opacity: 0.85;
}

.nav-item .nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  background: var(--color-red);
  color: #fff;
  border-radius: 14px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
  line-height: 16px;
}

.nav-item.active .nav-badge {
  background: rgba(255, 255, 255, 0.18);
  color: var(--sidebar-item-active-text);
}

/* Sidebar footer */
.sidebar-footer {
  padding: 10px 8px 14px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-footer-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.sidebar-footer-actions .user-row {
  flex: 1;
  min-width: 0;
}

.sidebar-logout-btn {
  flex-shrink: 0;
  color: var(--sidebar-text-muted);
}

.sidebar-logout-btn:hover {
  color: var(--color-red) !important;
  background: rgba(239, 68, 68, 0.08) !important;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 12px;
  transition: background 0.1s;
}

.user-row:hover {
  background: var(--sidebar-item-hover-bg);
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--sidebar-text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role {
  font-size: 11px;
  color: var(--sidebar-text-muted);
  margin-top: 1px;
}

.user-chevron {
  color: var(--sidebar-text-muted);
  flex-shrink: 0;
}

/* Sidebar clara/escura agora vem 100% dos tokens --sidebar-* (tokens.css),
   editáveis em Admin → Aparência. Sem overrides hardcoded aqui. */

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ---- Toolbar ---- */
.toolbar {
  height: 56px;
  padding: 0 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--glass-border-inner);
  background: var(--glass-bg-toolbar);
  flex-shrink: 0;
  z-index: var(--z-toolbar);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.toolbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Page content ---- */
.page-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 40px 56px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

/* Largura máxima — previne esticamento em telas ultra-wide */
.page-content>* {
  width: 100%;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
  flex-shrink: 0;
}

/* Scroll suave */
.page-content,
.sidebar-nav {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

.page-content::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.page-content::-webkit-scrollbar-thumb,
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

/* ============================================================
   GRID LAYOUTS
   ============================================================ */
.grid-1 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

/* Módulo grid */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}


/* ============================================================
   MODULE CARD
   ============================================================ */
.module-card {
  background: var(--glass-bg-card);
  border: 1px solid var(--glass-border-outer);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  user-select: none;
  display: flex;
  flex-direction: column;
}

.module-card:hover {
  background: var(--control-bg-hover);
}

.module-card:active {
  background: var(--fill-secondary);
}

/* Thumbnail */
.module-thumb-wrapper {
  position: relative;
  flex-shrink: 0;
}

.module-thumb {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  display: block;
  background: var(--control-border);
}

.module-thumb-placeholder {
  width: 100%;
  aspect-ratio: 3/4;
  background: var(--control-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
}

/* Locked state */
.module-card.locked .module-thumb {
  filter: saturate(0.25) brightness(0.65);
}

.lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.12);
}

.lock-icon-wrap {
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  filter: none !important;
}

/* Module body */
.module-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.module-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.module-category {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(var(--accent-rgb), 0.08);
  padding: 2px 7px;
  border-radius: 20px;
}

.module-duration {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
}

.module-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.module-description {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
  flex: 1;
}

.module-progress {
  height: 4px;
  background: var(--divider);
  border-radius: 2px;
  overflow: hidden;
  margin-top: auto;
}

.module-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: none;
}

.module-progress-bar.completed {
  background: var(--color-green);
}

/* ============================================================
   NOTIFICATION BELL
   ============================================================ */
.notif-btn {
  position: relative;
}

.notif-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  background: var(--color-red);
  border-radius: 50%;
  border: 1px solid var(--glass-bg-toolbar);
}

/* ============================================================
   BANNER CAROUSEL
   ============================================================ */
.banner-carousel {
  width: 100%;
  height: 160px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--glass-bg-card);
  border: 1px solid var(--glass-border-outer);
  position: relative;
}

.banner-slide {
  display: none;
  width: 100%;
  height: 100%;
  /* resolve contra os 160px do pai — sem ambiguidade */
}

.banner-slide.active {
  display: block;
}

.banner-carousel-link {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
}

.banner-carousel-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ---- Banner sem imagem: mesh gradient + pattern + título tipográfico ---- */
.banner-carousel-placeholder {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  height: 100%;
  padding: 28px 36px;
  color: var(--on-accent);
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(ellipse at 12% 20%,
      color-mix(in srgb, var(--accent) 78%, var(--color-purple) 22%) 0%,
      transparent 55%),
    radial-gradient(ellipse at 88% 85%,
      color-mix(in srgb, var(--accent) 60%, var(--color-teal) 40%) 0%,
      transparent 60%),
    radial-gradient(ellipse at 55% 45%,
      color-mix(in srgb, var(--accent) 85%, var(--color-indigo) 15%) 0%,
      transparent 70%),
    linear-gradient(135deg,
      color-mix(in srgb, var(--accent) 92%, black 8%) 0%,
      color-mix(in srgb, var(--accent) 75%, var(--color-purple) 25%) 100%);
}

/* Grid sutil sobreposto (pattern geométrico) */
.banner-carousel-placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(0deg,  rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: -1px -1px;
  mask-image: radial-gradient(ellipse at 70% 30%, #000 40%, transparent 85%);
  -webkit-mask-image: radial-gradient(ellipse at 70% 30%, #000 40%, transparent 85%);
  opacity: 0.65;
}

/* Shine diagonal que percorre o banner lentamente */
.banner-carousel-placeholder::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(115deg,
    transparent 30%,
    rgba(255, 255, 255, 0.14) 48%,
    rgba(255, 255, 255, 0.22) 50%,
    rgba(255, 255, 255, 0.14) 52%,
    transparent 70%);
  transform: translateX(-60%);
  display: none;
  pointer-events: none;
}

.banner-carousel-placeholder strong {
  position: relative;
  z-index: 1;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  max-width: 70%;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
}

/* Glyph decorativo grande, no canto direito */
.banner-carousel-placeholder strong::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -180%;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  transform: translateY(-50%);
  pointer-events: none;
}


@media (max-width: 600px) {
  .banner-carousel-placeholder {
    padding: 18px 22px;
  }
  .banner-carousel-placeholder strong {
    font-size: 17px;
    max-width: 78%;
  }
  .banner-carousel-placeholder strong::after {
    width: 140px;
    height: 140px;
    right: -140%;
  }
}

.banner-dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  z-index: 2;
}

.banner-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 0.1s;
  flex-shrink: 0;
}

.banner-dot.active {
  background: #fff;
}

/* Banner dentro de views — evita espaço vazio quando ausente */
#banner-course,
#banner-lesson,
#banner-top {
  min-height: 0;
}

#banner-course:empty,
#banner-lesson:empty,
#banner-top:empty {
  display: none;
}

@media (max-width: 600px) {
  .banner-carousel {
    height: 140px;
    border-radius: 12px;
  }
}

/* ============================================================
   POPUP / PROMO MODAL
   ============================================================ */
.promo-popup {
  max-width: 460px;
  text-align: center;
}

.promo-popup .popup-img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 14px;
  margin-bottom: 14px;
}

.promo-popup h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.promo-popup p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 18px;
}

.unlock-popup .module-preview {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--control-bg);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 18px;
  text-align: left;
}

.unlock-popup .module-preview img {
  width: 68px;
  height: 50px;
  object-fit: cover;
  border-radius: 7px;
  filter: saturate(0.3) brightness(0.7);
  flex-shrink: 0;
}

.unlock-popup .preview-info {
  flex: 1;
}

.unlock-popup .preview-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 3px;
}

.unlock-popup .preview-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.price-tag {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-weight: 700;
  color: var(--text-primary);
}

.price-tag .currency {
  font-size: 14px;
}

.price-tag .amount {
  font-size: 30px;
  letter-spacing: -0.03em;
}

.price-tag .cents {
  font-size: 14px;
}

/* ============================================================
   SIDEBAR OVERLAY (mobile)
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: calc(var(--z-sidebar) - 1);
}

.sidebar-overlay.visible {
  display: block;
}

/* ============================================================
   RESPONSIVE — Ultrawide (≥1600px)
   ============================================================ */
@media (min-width: 1600px) {
  .sidebar {
    width: 272px;
  }

  .toolbar {
    padding: 0 72px;
  }

  .page-content {
    padding: 48px 72px;
  }

  .module-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }

  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }

  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================================
   RESPONSIVE — Desktop normal (900–1599px)
   ============================================================ */
@media (max-width: 1400px) {
  .module-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

/* ============================================================
   RESPONSIVE — Tablet landscape / Notebook pequeno (≤1100px)
   ============================================================ */
@media (max-width: 1100px) {
  .sidebar {
    width: 232px;
  }

  .page-content {
    padding: 24px 32px;
    gap: 32px;
  }

  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================================
   RESPONSIVE — Tablet / Mobile large (≤900px)
   ============================================================ */
@media (max-width: 900px) {
  /* Remove a isolação do app-shell para a z-index do sidebar escapar e
     ficar acima do overlay no nível do body. */
  .app-shell {
    isolation: auto;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    z-index: var(--z-popup);
    pointer-events: auto;
  }

  /* Overlay só cobre a área à direita do sidebar — nunca fica sobre
     o menu, então os cliques em .nav-item chegam sem bloqueio. */
  .sidebar-overlay {
    z-index: var(--z-modal);
    background: rgba(0, 0, 0, 0.25);
    left: 280px;
  }

  .main-area {
    transition: none;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .page-content {
    padding: 16px 18px;
  }

  .toolbar {
    padding: 0 18px;
  }

  .grid-4,
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .module-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

/* ============================================================
   RESPONSIVE — Mobile (≤600px)
   ============================================================ */
@media (max-width: 600px) {
  .page-content {
    padding: 16px 16px;
    gap: 18px;
  }

  .toolbar {
    height: 56px;
    padding: 0 16px;
  }

  #toolbar-title {
    font-size: 16px;
  }

  .module-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .course-section-heading,
  h2 {
    font-size: 18px;
  }
}

/* ============================================================
   RESPONSIVE — Mobile pequeno (≤400px)
   ============================================================ */
@media (max-width: 400px) {

  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .module-grid {
    grid-template-columns: 1fr;
  }

  .page-content {
    padding: 10px;
  }
}

/* ============================================================
   BOTTOM NAV (mobile)
   ============================================================ */
.bottom-nav {
  display: none;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 500;
  font-family: var(--font-system);
  padding: 6px 0;
  transition: color 0.12s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  letter-spacing: 0.01em;
}

.bottom-nav-item.active {
  color: var(--accent);
}

.bottom-nav-item:active {
  opacity: 0.65;
}

/* Mesmo breakpoint em que o sidebar vira off-canvas (≤900px) —
   evita a faixa 769–900px sem nenhuma navegação visível. */
@media (max-width: 900px) {
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--glass-bg-toolbar);
    border-top: 1px solid var(--glass-border-inner);
    z-index: var(--z-toolbar);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Espaço para não sobrepor conteúdo */
  .page-content {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 16px);
  }
}