/* ============================================================
   RESPONSIVE MOBILE — CursosFlix
   Breakpoints: ≤768px (mobile), 769–1024px (tablet)
   Estratégia:
     - Sidebar se torna um drawer lateral (slide from left)
     - Hambúrguer na top bar abre/fecha drawer
     - Bottom nav bar com atalhos principais
     - Grid de cards 2 col no mobile, 3 col no tablet
     - Modal de curso empilhado verticalmente
     - Top bar compacta (busca ocupa linha própria)
   ============================================================ */

/* ─── TABLET (769 – 1024px) ────────────────────────────────── */
@media (max-width: 1024px) {
  .retro-sidebar {
    width: 200px;
    min-width: 200px;
    max-width: 200px;
  }

  .retro-search-pill {
    width: 200px;
  }

  .retro-cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .desktop-modal-box {
    max-width: 700px;
  }

  .desktop-modal-left {
    width: 240px;
    min-width: 240px;
  }
}

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

  /* ── Layout root ── */
  .retro-app-layout {
    flex-direction: column;
    position: relative;
    overflow: hidden;
  }

  /* ── SIDEBAR → DRAWER ── */
  .retro-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    height: 100%;
    z-index: 3000;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 32px rgba(0,0,0,0.8);
  }

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

  /* Overlay escuro atrás do drawer */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 2999;
    backdrop-filter: blur(3px);
  }

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

  /* ── MAIN AREA ocupa tela toda ── */
  .retro-main-area {
    width: 100%;
    height: 100vh;
    flex: 1;
  }

  /* ── TOP BAR mobile ── */
  .retro-top-bar {
    flex-wrap: wrap;
    height: auto;
    min-height: 56px;
    padding: 10px 14px 8px;
    gap: 8px;
    align-items: center;
  }

  /* Hamburguer + Logo no topo */
  .mobile-topbar-row {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 10px;
  }

  .retro-hamburger {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #1c2130;
    border: 1px solid var(--border-subtle);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    flex-shrink: 0;
  }

  /* Busca ocupa linha própria abaixo */
  .retro-search-pill {
    width: 100%;
    order: 10;
    flex: 1 1 100%;
  }

  /* Ocultar seletor de quantidade e botões extras no mobile pequeno */
  .retro-top-center {
    display: none;
  }

  /* Apenas ícone de gestão (sem texto) */
  .retro-top-right .retro-pill-btn span:not(.cyan-dot) {
    display: none;
  }

  .retro-top-right {
    margin-left: auto;
    flex-shrink: 0;
  }

  /* ── SCROLL CONTENT ── */
  .retro-scroll-content {
    padding: 14px 12px 90px; /* 90px para não cobrir bottom nav */
  }

  /* ── CONTENT HEADER ── */
  .retro-content-header {
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
  }

  .retro-title-text {
    font-size: 16px;
  }

  .retro-item-counter {
    width: 100%;
    text-align: left;
  }

  /* ── GRID DE CARDS: 2 colunas fixas no mobile ── */
  .retro-cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .retro-card-title {
    font-size: 12px;
  }

  /* ── MODAL DE CURSO → empilhado vertical ── */
  .desktop-modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .desktop-modal-box {
    flex-direction: column;
    max-width: 100%;
    width: 100%;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
  }

  .desktop-modal-left {
    width: 100%;
    min-width: unset;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
  }

  .desktop-modal-cover {
    width: 110px;
    min-width: 110px;
    aspect-ratio: 4/3;
    margin-bottom: 0;
    border-radius: 8px;
  }

  /* Container de botões da esquerda no mobile */
  .desktop-modal-left > button,
  .desktop-modal-left > a {
    flex: 1 1 calc(50% - 6px);
    margin: 0 !important;
  }

  .desktop-modal-left #btnDesktopPlay {
    flex: 1 1 100%;
    order: -1;
  }

  .desktop-modal-right {
    padding: 16px 18px 24px;
    overflow-y: auto;
  }

  .desktop-modal-title {
    font-size: 16px;
  }

  #desktopModalList {
    max-height: 35vh !important;
  }

  /* ── MODALS GERAIS ── */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    max-width: 100%;
    width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 90vh;
  }

  .modal-body {
    max-height: 70vh;
    padding: 16px;
  }

  /* ── ESTILOS ESPECÍFICOS DO PLAYER MOBILE (player.html) ── */
  body.player-page {
    height: auto !important;
    min-height: 100vh !important;
    overflow-y: auto !important;
    display: flex;
    flex-direction: column;
  }

  body.player-page .navbar {
    padding: 0.5rem 0.85rem !important;
    height: 48px !important;
    position: sticky;
    top: 0;
    z-index: 1000;
  }

  .player-layout {
    flex-direction: column !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .player-main {
    flex: none !important;
    overflow: visible !important;
    height: auto !important;
  }

  .video-container {
    max-height: 36vh !important;
    position: sticky !important;
    top: 48px;
    z-index: 900;
  }

  video {
    max-height: 36vh !important;
  }

  .video-info {
    padding: 1rem 0.85rem !important;
  }

  .video-header {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.85rem !important;
    margin-bottom: 0.75rem !important;
  }

  .video-header > div:last-child {
    display: flex !important;
    width: 100% !important;
    gap: 0.5rem !important;
    justify-content: space-between !important;
  }

  .video-header .btn {
    flex: 1 !important;
    justify-content: center !important;
    padding: 0.5rem 0.4rem !important;
    font-size: 0.78rem !important;
    white-space: nowrap !important;
  }

  .video-title {
    font-size: 1.1rem !important;
  }

  .player-sidebar {
    width: 100% !important;
    min-width: 100% !important;
    border-left: none !important;
    border-top: 1px solid var(--border-subtle) !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    flex: none !important;
  }

  .modules-list {
    max-height: 55vh !important;
    overflow-y: auto !important;
  }

  .lesson-item {
    padding: 0.85rem 1rem !important;
    font-size: 0.88rem !important;
  }

  /* ── BOTTOM NAV BAR ── */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #090b10;
    border-top: 1px solid var(--border-subtle);
    z-index: 2500;
    align-items: stretch;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.6);
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    color: var(--text-dim);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    border: none;
    background: transparent;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
    padding: 0 4px;
  }

  .mobile-nav-item i {
    font-size: 18px;
  }

  .mobile-nav-item.active {
    color: var(--color-amber);
  }

  .mobile-nav-item:active {
    opacity: 0.7;
  }

  /* ── HEADER DROPDOWN ── */
  .header-dropdown-menu {
    right: 0;
    left: auto;
    width: 200px;
  }
}

/* ─── MOBILE XS (≤380px) ───────────────────────────────────── */
@media (max-width: 380px) {
  .retro-cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .retro-card-title {
    font-size: 11px;
  }

  .desktop-modal-cover {
    width: 110px;
    min-width: 110px;
  }
}

/* ─── DESKTOP: ocultar elementos mobile-only ─────────────────── */
@media (min-width: 769px) {
  .mobile-bottom-nav {
    display: none;
  }
  .retro-hamburger {
    display: none;
  }
  .mobile-topbar-row {
    display: none;
  }
  .sidebar-overlay {
    display: none !important;
  }
}
