
/* =========================================================
   BADBEAR.MED - RESPONSIVE GLOBAL V21
   Desktop ancho + menú móvil universal
   ========================================================= */

:root{
  --bb-global-desktop-max: 1500px;
  --bb-global-desktop-gap: 28px;
}

/* ---------- DESKTOP ---------- */
@media (min-width: 1100px){

  /* Contenedores detectados por el JS global */
  html body .bb-global-wide{
    width: min(var(--bb-global-desktop-max), calc(100vw - 56px)) !important;
    max-width: var(--bb-global-desktop-max) !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  /*
    Permite que un contenido angosto salga de un wrapper padre antiguo,
    manteniéndose centrado en la pantalla.
  */
  html body .bb-global-wide.bb-global-centered{
    position: relative !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
  }

  /* Páginas de teoría/tema que ya conocemos */
  html body .bb-clean-study-layout,
  html body .bb-study-layout{
    width: min(1450px, calc(100vw - 64px)) !important;
    max-width: 1450px !important;
    grid-template-columns: minmax(0, 1fr) 260px !important;
    gap: 26px !important;
  }

  html body .bb-clean-study-main,
  html body .bb-study-main{
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
  }

  html body .bb-clean-study-aside,
  html body .bb-study-sidebar{
    width: 260px !important;
    max-width: 260px !important;
  }

  /* Evita que shells compartidos vuelvan a quedar en 980–1100 px */
  html body .bb-shell,
  html body .course-shell,
  html body .module-shell,
  html body .portal-shell,
  html body .page-shell,
  html body .main-shell{
    max-width: var(--bb-global-desktop-max) !important;
  }
}

/* ---------- MENÚ MÓVIL UNIVERSAL ---------- */
.bb-global-menu-toggle{
  display:none;
}

.bb-global-mobile-menu{
  display:none;
}

/* ---------- TABLET / CELULAR ---------- */
@media (max-width: 820px){

  html,body{
    max-width:100%;
    overflow-x:hidden;
  }

  /* Botón ☰ siempre accesible */
  .bb-global-menu-toggle{
    display:inline-flex !important;
    position:fixed !important;
    top:max(10px, env(safe-area-inset-top)) !important;
    right:10px !important;
    z-index:2147483000 !important;
    align-items:center !important;
    justify-content:center !important;
    gap:7px !important;
    min-width:46px !important;
    min-height:44px !important;
    padding:9px 12px !important;
    border:1px solid #d9e5f5 !important;
    border-radius:12px !important;
    background:#ffffff !important;
    color:#155eef !important;
    box-shadow:0 8px 24px rgba(15,23,42,.14) !important;
    font:800 14px/1 system-ui,-apple-system,"Segoe UI",Arial,sans-serif !important;
    cursor:pointer !important;
  }

  .bb-global-menu-toggle .bb-global-menu-bars{
    font-size:22px !important;
    line-height:1 !important;
  }

  /* La navegación original se reemplaza por el menú compacto */
  .bb-global-nav-source{
    display:none !important;
  }

  .bb-global-mobile-menu{
    position:fixed !important;
    top:64px !important;
    left:10px !important;
    right:10px !important;
    z-index:2147482999 !important;
    max-height:calc(100dvh - 82px) !important;
    overflow:auto !important;
    padding:10px !important;
    border:1px solid #dbe5f2 !important;
    border-radius:16px !important;
    background:rgba(255,255,255,.98) !important;
    box-shadow:0 18px 50px rgba(15,23,42,.2) !important;
    backdrop-filter:blur(10px) !important;
  }

  .bb-global-mobile-menu.is-open{
    display:grid !important;
    grid-template-columns:1fr !important;
    gap:6px !important;
  }

  .bb-global-mobile-menu a{
    display:flex !important;
    align-items:center !important;
    min-height:46px !important;
    padding:11px 13px !important;
    border-radius:11px !important;
    color:#24324a !important;
    background:#f8fafc !important;
    font:800 14px/1.25 system-ui,-apple-system,"Segoe UI",Arial,sans-serif !important;
    text-decoration:none !important;
  }

  .bb-global-mobile-menu a:hover,
  .bb-global-mobile-menu a:focus{
    background:#eaf2ff !important;
    color:#155eef !important;
  }

  /* Todo vuelve a una sola columna en móvil */
  html body .bb-global-wide,
  html body .bb-global-wide.bb-global-centered,
  html body .bb-clean-study-layout,
  html body .bb-study-layout{
    width:calc(100% - 16px) !important;
    max-width:none !important;
    left:auto !important;
    transform:none !important;
    margin-left:auto !important;
    margin-right:auto !important;
  }

  html body .bb-clean-study-layout,
  html body .bb-study-layout{
    grid-template-columns:1fr !important;
    gap:16px !important;
  }

  html body .bb-clean-study-aside,
  html body .bb-study-sidebar{
    position:static !important;
    width:100% !important;
    max-width:none !important;
  }

  /* Tarjetas y grids comunes */
  html body .bb-grid,
  html body .course-grid,
  html body .topics-grid,
  html body .cards-grid,
  html body .resource-grid{
    grid-template-columns:1fr !important;
  }

  /* Medios no deben desbordar */
  img,video,iframe,audio{
    max-width:100% !important;
  }

  iframe{
    width:100% !important;
  }
}

/* Teléfonos pequeños */
@media (max-width: 480px){
  .bb-global-menu-toggle{
    top:max(8px, env(safe-area-inset-top)) !important;
    right:8px !important;
    min-width:44px !important;
    padding:8px 10px !important;
  }

  .bb-global-menu-toggle .bb-global-menu-label{
    display:none !important;
  }

  .bb-global-mobile-menu{
    top:58px !important;
    left:7px !important;
    right:7px !important;
  }
}
