/* ==========================================================
   RESPONSIVE MOBILE — YBT app-interaccion
   Agregar al final del CSS existente (o importar como hoja separada)
   Breakpoints:
     ≤ 980px  → rail compacto (solo íconos)       [ya existía parcialmente]
     ≤ 768px  → bottom nav + layout de 1 columna
     ≤ 480px  → ajustes finos de tipografía/cards
   ========================================================== */

/* ----------------------------------------------------------
   VARIABLES EXTRA MOBILE
   ---------------------------------------------------------- */
:root {
  --bottom-nav-h: 62px; /* alto de la barra inferior en mobile */
}

/* ===========================================================
   BREAKPOINT 980px — rail compacto (refuerza lo que ya existe)
   =========================================================== */
@media (max-width: 980px) {

  /* Notificaciones: overlay en lugar de columna */
  .grid-interaccion.has-left-notifs {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .left-notifs {
    position: fixed;
    inset: 0 auto 0 88px;
    width: min(340px, calc(100vw - 96px));
    min-height: 100dvh;
    max-height: 100dvh;
    z-index: 60;
    border-radius: 0 18px 18px 0;
    transform: translateX(-110%);
    transition: transform .22s ease;
  }
  .left-notifs.is-open { transform: translateX(0); }

  /* Overlay oscuro cuando las notificaciones están abiertas */
  .left-notifs.is-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
  }

  /* Grid del hero: asegurar que el avatar no rompa */
  .profile-hero .hero-body {
    gap: 10px;
  }

}

/* ===========================================================
   BREAKPOINT 768px — BOTTOM NAV + layout mobile completo
   =========================================================== */
@media (max-width: 768px) {

  /* ── LAYOUT PRINCIPAL ── */
  .grid-interaccion {
    flex-direction: column;
    gap: 0;
    height: auto;           /* deja que el contenido dicte la altura */
    min-height: 100dvh;
    overflow: visible;
    padding-bottom: var(--bottom-nav-h); /* espacio para el bottom nav */
  }

  /* ── RAIL → BOTTOM NAV ── */
  .grid-interaccion > .left-rail {
    /* Neutraliza el position:static del contexto .grid-interaccion */
    position: fixed !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;

    /* Layout horizontal */
    flex-direction: row !important;
    flex: none !important;
    align-self: auto !important;
    align-items: center;
    justify-content: space-around;

    height: var(--bottom-nav-h);
    padding: 0 8px !important;
    gap: 0 !important;
    z-index: 50;
    border-top: 1px solid var(--border) !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    border-radius: 0 !important;
    box-shadow: 0 -4px 18px rgba(0, 0, 0, .22) !important;
  }

  /* Ítems del rail en modo barra inferior */
  .left-rail .rail-item {
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 3px !important;
    width: auto !important;
    flex: 1 1 0 !important;
    padding: 6px 4px !important;
    border-radius: 12px !important;
    min-height: 50px;
  }

  .left-rail .rail-item .icon {
    font-size: 20px !important;
    line-height: 1;
  }

  .left-rail .rail-item .label {
    display: block !important;   /* override del ≤980px que lo oculta */
    font-size: 10px !important;
    line-height: 1;
    opacity: .82;
  }

  /* Badge de notificaciones */
  .rail-badge {
    top: 4px;
    right: 14px;
  }

  /* ── COLUMNA DERECHA ── */
  .col.derecha {
    width: 100%;
    overflow: visible;
    height: auto;
  }

  /* ── HERO PERFIL ── */
  .profile-hero .hero-cover {
    height: 180px;
  }

  .profile-hero .hero-body {
    top: 50%;
    bottom: auto;
    left: 12px;
    right: 12px;
    gap: 10px;
    transform: translateY(-50%);
  }

  .profile-hero .avatar {
    width: 72px;
    height: 72px;
  }

  .profile-hero .name { font-size: 16px; }
  .profile-hero .handle { font-size: 13px; }
  .profile-hero .bio { font-size: 13px; }
  .profile-hero .stats { gap: 10px; }
  .profile-hero .stat strong { font-size: 15px; }
  .profile-hero .stat span { font-size: 11px; }

  /* ── TABS DE CONTENIDO ── */
  #contenidoTabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 8px 0 6px;
    gap: 8px;
  }
  #contenidoTabs::-webkit-scrollbar { display: none; }

  .contenido-tab {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  /* ── GRID DE CONTENIDO SUBIDO ── */
  .contenido-subido {
    grid-template-columns: repeat(2, 1fr);
    overflow: visible;
  }

  .item-contenido video {
    height: 220px;
    aspect-ratio: 9 / 16;
  }

  /* ── ASIDE NOTIFICACIONES (full overlay en mobile) ── */
  .left-notifs {
    inset: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
    min-height: 100dvh;
    max-height: 100dvh;
    transform: translateX(-100%);
  }
  .left-notifs.is-open { transform: translateX(0); }

  /* ── MODALES ── */
  .modal__dialog {
    margin: 0 auto 0;
    width: 100% !important;
    max-width: 100vw !important;
    border-radius: 20px 20px 0 0 !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 95dvh !important;
    animation: modalSlideUp .2s ease-out;
  }

  @keyframes modalSlideUp {
    from { transform: translateY(30px); opacity: .92; }
    to   { transform: none; opacity: 1; }
  }

  /* Modal compose: columna única */
  .modal__dialog.is-compose .modal__body {
    grid-template-columns: 1fr;
    overflow: auto;
    padding: 12px;
  }

  .modal__dialog.is-compose .compose-preview {
    position: relative;
    top: auto;
  }

  #previewVideo {
    height: 40vb;
    aspect-ratio: 16 / 9;
  }

  /* Modal detalle: columna única */
  .modal__dialog.is-detail .vd-grid {
    grid-template-columns: 1fr !important;
    height: auto !important;
  }

  .modal__dialog.is-detail .vd-left video {
    height: 50vb;
    max-height: 60dvh;
  }

  /* Modal perfil */
  .modal__dialog.is-perfil .cover-box {
    min-height: 200px;
    height: 200px;
  }

  /* ── ASIDE DE BÚSQUEDA ── */
  .search-aside__panel {
    width: 100vw;
    left: 0;
    right: 0;
  }

  /* ── ASIDE DE COMENTARIOS (FEED) ── */
  .feed-comments-panel {
    width: 100vw !important;
    max-width: 100vw !important;
    border-left: none !important;
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
    top: auto !important;
    bottom: 0 !important;
    height: 80dvh !important;
  }

  /* ── FEED TikTok ── */
  .contenido-feed {
    max-width: 100%;
  }

  .feed-item.tiktok-feed {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .feed-video {
    height: calc(100dvh - var(--bottom-nav-h) - 16px);
    min-height: 480px;
  }

  .feed-actions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px 12px;
    padding: 0 4px;
  }

  /* ── FEED NAV (botones prev/next) ── */
  .grid-interaccion[data-view="scroll"] .feed-nav {
    right: 10px;
    gap: 8px;
    /* sube para no chocar con el bottom nav */
    bottom: calc(var(--bottom-nav-h) + 12px);
    top: auto;
    transform: none;
  }
  .grid-interaccion[data-view="scroll"] .feed-nav .btn {
    width: 46px;
    height: 46px;
    border-radius: 14px;
  }

  /* ── FORM ACTIONS sticky ── */
  .col.derecha > .form-actions {
    top: 0;
  }
}

/* ===========================================================
   BREAKPOINT 480px — ajustes finos
   =========================================================== */
@media (max-width: 480px) {

  /* Una sola columna para contenido subido en pantallas muy pequeñas */
  .contenido-subido {
    grid-template-columns: 1fr;
  }

  .item-contenido video {
    height: 260px;
  }

  /* Hero más compacto */
  .profile-hero .hero-cover { height: 230px !important;  }
  .profile-hero .avatar { width: 60px; height: 60px; }
  .profile-hero .name { font-size: 15px; }

  .profile-hero {
    position: relative;
    overflow: hidden;
    min-height: 230px !important;
    padding: 0;
}

  /* Botones del hero */
  .profile-hero .actions .btn {
    height: 32px;
    padding: 0 10px;
    font-size: 13px;
  }

  /* Chips de búsqueda */
  .search-chip {
    font-size: 13px;
    padding: 6px 10px;
  }

  /* Notificaciones: padding más ajustado */
  .left-notifs__head { padding: 12px; }
  .left-notifs__list { padding: 8px; }
  .left-notifs__filters { padding: 4px 8px; }

  /* Modal: altura máxima ajustada */
  .modal__dialog {
    max-height: 98dvh !important;
  }

  /* feed */
  .feed-video {
    height: calc(100dvh - var(--bottom-nav-h) - 8px);
    min-height: 420px;
  }

  /* tabs de tipo de contenido */
  #contenidoTabs button.contenido-tab {
    height: 32px;
    padding: 0 10px;
    font-size: 13px;
  }

  /* rail badge — posición ajustada a barra inferior */
  .rail-badge {
    top: 6px;
    right: 10px;
    min-width: 16px;
    height: 16px;
    font-size: 9px;
  }

  /* comentarios del feed ocupan más pantalla */
  .feed-comments-panel {
    height: 92dvh !important;
  }
}

/* ===========================================================
   MEJORAS TÁCTILES GLOBALES (aplican a todos los tamaños touch)
   =========================================================== */
@media (hover: none) {

  /* Eliminar efectos hover que en touch quedan "pegados" */
  .btn:hover,
  .rail-item:hover,
  .feed-actions .fab:hover,
  .notif-item:hover,
  .search-result-item:hover {
    transform: none;
    box-shadow: none;
    background: unset;
  }

  /* Tap highlight coherente */
  .btn, .rail-item, .fab, .notif-item, .search-result-item {
    -webkit-tap-highlight-color: rgba(79, 140, 255, .18);
  }

  /* Targets táctiles mínimos (44px) */
  .btn, .rail-item, .notif-filter, .search-chip, .mini-btn {
    min-height: 44px;
  }

  /* Mantener min-height para mini-btn pero sin forzar altura visual */
  .mini-btn {
    min-height: 40px; /* ligeramente más permisivo en mini */
  }
}

@media (max-width: 480px) {
  .contenido-subido {
    grid-template-columns: repeat(2, 1fr) !important; /* mantiene 2 columnas */
  }

  .item-contenido video {
    height: 100px;
  }
}