/* ==========================================================================
   BINNDER — MOBILE ADAPTIVE STYLESHEET
   Todos los overrides para pantallas ≤ 768px.
   El archivo index.css (desktop) NO se modifica.
   ========================================================================== */

/* ── Variables extra para móvil ─────────────────────────────────────────── */
:root {
    --mob-nav-h:   68px;
    --mob-top-h:   56px;
    --safe-bot:    env(safe-area-inset-bottom, 0px);
    --safe-top:    env(safe-area-inset-top, 0px);
}

/* ==========================================================================
   BOTTOM TAB BAR (visible solo en móvil)
   ========================================================================== */
.mobile-bottom-nav {
    display: none; /* Oculto por defecto en desktop */
}

/* ==========================================================================
   SECCIÓN MÓVIL — max-width: 768px
   ========================================================================== */
@media (max-width: 768px) {

    /* ── Body ────────────────────────────────────────────────────────────── */
    body {
        padding-bottom: calc(var(--mob-nav-h) + var(--safe-bot));
        overflow-x: hidden;
    }

    /* ── TOP NAVBAR ──────────────────────────────────────────────────────── */
    .navbar {
        padding: 0 1rem 0 1rem;
        height: var(--mob-top-h);
        position: sticky;
        top: 0;
    }

    .nav-logo-text {
        font-size: 1.15rem;
        letter-spacing: 1.5px;
    }

    /* Ya oculto en index.css, reconfirmamos */
    .nav-links { display: none; }

    /* Ocultar botón "Subir carta" del nav (se mueve al tab central) */
    .btn-nav-sell { display: none; }

    /* Ocultar widget de sesión del top nav — lo reemplaza el tab "Perfil" */
    #user-session-widget { display: none !important; }

    /* Compactar acciones del nav */
    .nav-actions { gap: 0.6rem; }

    /* ── BOTTOM TAB NAVIGATION ───────────────────────────────────────────── */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: var(--mob-nav-h);
        padding-bottom: var(--safe-bot);
        background: rgba(5, 10, 25, 0.97);
        backdrop-filter: blur(30px) saturate(180%);
        border-top: 1px solid rgba(255, 255, 255, 0.07);
        z-index: 500;
        align-items: center;
        justify-content: space-around;
    }

    .mobile-tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        flex: 1;
        height: 100%;
        text-decoration: none;
        color: var(--text-muted);
        font-family: var(--font-b);
        font-size: 0.66rem;
        font-weight: 500;
        background: none;
        border: none;
        cursor: pointer;
        transition: color 0.2s var(--ease-smooth);
        padding: 0;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
    }

    .mobile-tab svg {
        transition: transform 0.25s var(--ease-spring);
        flex-shrink: 0;
    }

    .mobile-tab.active {
        color: var(--primary);
    }

    .mobile-tab.active svg {
        transform: translateY(-2px) scale(1.08);
    }

    /* Botón central de Subir (elevado y destacado) */
    .mobile-tab-center { position: relative; }

    .mobile-upload-btn {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--primary), var(--secondary));
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 20px rgba(0, 102, 255, 0.55);
        transform: translateY(-8px);
        transition: transform 0.2s var(--ease-spring), box-shadow 0.2s;
        margin-bottom: 2px;
    }

    .mobile-tab-center:active .mobile-upload-btn {
        transform: translateY(-6px) scale(0.95);
        box-shadow: 0 2px 12px rgba(0, 102, 255, 0.4);
    }

    /* Avatar circular en el tab de perfil */
    .mob-avatar-wrap {
        width: 26px;
        height: 26px;
        border-radius: 50%;
        border: 2px solid rgba(255, 255, 255, 0.2);
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
        background: linear-gradient(135deg, var(--primary), var(--secondary));
        transition: border-color 0.2s;
    }

    .mobile-tab.active .mob-avatar-wrap {
        border-color: var(--primary);
    }

    /* ── SPLASH SCREEN ───────────────────────────────────────────────────── */
    .btn-skip-splash {
        top: calc(var(--safe-top) + 16px);
        right: 16px;
    }

    /* ── HERO SECTION ───────────────────────────────────────────────────── */
    .hero-section {
        display: flex;
        flex-direction: column;
        padding: 1.75rem 1.25rem 2rem;
        gap: 0;
        text-align: center;
        max-width: 100%;
    }

    /* Mazo 3D encima del texto */
    .hero-cards-side {
        order: -1;
        width: 100%;
        margin-bottom: 1.25rem;
    }

    .deck-container {
        height: 210px;
        width: 100%;
        perspective: 900px;
    }

    .interactive-card {
        width: 100px;
        height: 143px;
        border-radius: 10px;
    }

    /* Texto del hero centrado */
    .hero-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .hero-badge {
        font-size: 0.75rem;
        margin-bottom: 1rem;
    }

    .hero-title {
        font-size: 1.95rem;
        line-height: 1.18;
        margin-bottom: 0.75rem;
    }

    .hero-desc {
        font-size: 0.88rem;
        max-width: 320px;
        line-height: 1.6;
        margin-bottom: 1.5rem;
    }

    .hero-cta {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }

    .hero-cta .btn {
        width: 100%;
        justify-content: center;
        padding: 0.9rem 1.5rem;
        font-size: 1rem;
    }

    .hero-stats {
        justify-content: center;
        gap: 1rem;
    }

    /* ── PILLARS SECTION ─────────────────────────────────────────────────── */
    .pillars-section {
        padding: 0 1.25rem;
    }

    .pillars-grid {
        grid-template-columns: 1fr;
        gap: 0.85rem;
    }

    .pillar-card {
        padding: 1.35rem 1.25rem;
        background: rgba(15, 25, 55, 0.75); /* Ligeramente más visible en móvil */
        border-color: rgba(255, 255, 255, 0.1);
    }

    /* ── MARKET CTA / TRADES ─────────────────────────────────────────────── */
    .trades-cta {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
        padding: 1.5rem 1.25rem;
    }

    /* ── GAMES SECTION ───────────────────────────────────────────────────── */
    .games-section {
        padding: 1.5rem 1.25rem;
    }

    .games-header h2 {
        font-size: 1.4rem;
    }

    .games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.65rem;
    }

    .game-chip {
        padding: 0.9rem 0.75rem;
        border-radius: 14px;
        font-size: 0.82rem;
    }

    /* ── MARKETPLACE ─────────────────────────────────────────────────────── */
    .marketplace-hero {
        padding: 1.5rem 1.25rem 1rem !important;
        text-align: left !important;
    }

    .marketplace-title {
        font-size: 1.9rem !important;
        margin-bottom: 0.35rem !important;
    }

    .marketplace-desc {
        font-size: 0.88rem !important;
        margin-bottom: 1rem !important;
        text-align: left;
    }

    /* Buscador de marketplace - full width */
    .search-bar-container {
        max-width: 100% !important;
        margin-bottom: 0.85rem !important;
    }

    /* Filter chips: scroll horizontal sin wrap */
    .filter-chips-container {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        justify-content: flex-start !important;
        margin-bottom: 1.25rem !important;
        padding: 0 0 0.5rem;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .filter-chips-container::-webkit-scrollbar { display: none; }

    .marketplace-grid-section {
        padding: 0 1.25rem 2rem !important;
    }

    /* Cards grid: 2 columnas en móvil */
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    /* Tarjeta TCG más compacta */
    .tcg-card-item {
        padding: 0.75rem;
        border-radius: 14px;
        gap: 0.6rem;
    }

    .tcg-card-img-container {
        height: 170px;
        border-radius: 10px;
    }

    .tcg-card-name {
        font-size: 0.82rem;
    }

    .tcg-card-price {
        font-size: 1.05rem;
    }

    .tcg-card-meta {
        font-size: 0.72rem;
    }

    /* Botón comprar carta en grid de 2 columnas */
    .tcg-card-buy-btn {
        font-size: 0.8rem !important;
        padding: 0.5rem 0.4rem !important;
        border-radius: 10px !important;
    }

    /* ── COLECCIÓN ───────────────────────────────────────────────────────── */
    .collection-dashboard {
        padding: 0 1rem 2rem !important;
        margin: 1rem auto !important;
    }

    .collection-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.85rem !important;
        margin-bottom: 1.25rem !important;
    }

    .collection-title {
        font-size: 1.75rem !important;
    }

    .collection-subtitle {
        font-size: 0.85rem !important;
    }

    /* Chip de valor total: ancho completo */
    .collection-total-chip {
        width: 100%;
        justify-content: space-between;
    }

    /* Carpetas en columna */
    .folders-container {
        flex-direction: column !important;
        gap: 0.65rem !important;
    }

    .folder-card {
        padding: 1rem 1.1rem;
        border-radius: 16px;
    }

    .folder-tab {
        font-size: 2rem;
    }

    /* Active folder view */
    .active-folder-view {
        padding: 1.1rem !important;
        border-radius: 18px !important;
    }

    .active-folder-header {
        margin-bottom: 1.25rem !important;
    }

    /* Buscador de colección */
    .tcg-search-input-wrapper {
        border-radius: 12px;
    }

    /* Filtros TCG: más compactos en scroll horizontal */
    .tcg-filter-row {
        gap: 0.6rem;
        margin-bottom: 1rem;
    }

    .tcg-filter-card {
        width: 96px;
        height: 132px;
        padding: 0.7rem 0.55rem;
        border-radius: 12px;
    }

    .tfc-icon   { font-size: 1.5rem; margin: 0.25rem 0; }
    .tfc-name   { font-size: 0.8rem; }
    .tfc-subname { font-size: 0.55rem; }

    /* Botón actualizar precios: compacto */
    #btn-refresh-all-prices {
        font-size: 0.75rem !important;
        padding: 0.4rem 0.7rem !important;
    }

    /* ── COLECCIÓN PÚBLICA ───────────────────────────────────────────────── */
    #view-public-collection > div {
        padding: 0 1rem 2rem !important;
        margin: 1rem auto !important;
    }

    #public-collection-header {
        gap: 0.75rem !important;
        margin-bottom: 1.25rem !important;
    }

    #public-collection-username {
        font-size: 1.4rem !important;
    }

    /* ── MODALES → BOTTOM SHEETS ─────────────────────────────────────────── */
    .modal-overlay {
        align-items: flex-end;
    }

    .modal-card {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 24px 24px 0 0 !important;
        max-height: 92dvh !important;
        transform: translateY(100%) !important;
        padding: 1.5rem 1.25rem calc(1.25rem + var(--safe-bot)) !important;
        /* Sobrescribir el scale inicial del desktop */
        transition: transform 0.42s var(--ease-spring) !important;
    }

    /* Drag handle decorativo */
    .modal-card::before {
        content: '';
        display: block;
        width: 38px;
        height: 4px;
        background: rgba(255, 255, 255, 0.16);
        border-radius: 4px;
        margin: 0 auto 1.25rem;
        flex-shrink: 0;
    }

    .modal-overlay.active .modal-card {
        transform: translateY(0) !important;
    }

    /* Modal de eliminación confirmación */
    #delete-confirm-modal .modal-card {
        text-align: center;
    }

    /* ── UPLOAD MODAL — Full screen en móvil ─────────────────────────────── */
    #upload-modal .modal-card {
        width: 100% !important;
        max-width: 100% !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        overflow-y: auto !important;
        transform: translateY(100%) !important;
        padding: 1.25rem 1rem calc(1rem + var(--safe-bot)) !important;
    }

    #upload-modal .modal-card::before {
        display: none; /* No drag handle en full screen */
    }

    #upload-modal.active .modal-card {
        transform: translateY(0) !important;
    }

    /* Formulario de upload: columna única */
    #upload-modal #form-upload-card {
        display: flex !important;
        flex-direction: column !important;
        gap: 1.25rem !important;
        overflow: visible !important;
        max-height: none !important;
    }

    #upload-modal .upload-left-col,
    #upload-modal .tcg-search-section {
        overflow: visible !important;
        max-height: none !important;
    }

    #upload-modal .tcg-search-results {
        max-height: 260px !important;
        grid-template-columns: repeat(3, 1fr) !important;
    }

    /* ── CARD DETAIL MODAL ───────────────────────────────────────────────── */
    #card-detail-modal .modal-card {
        max-height: 95dvh !important;
    }

    .card-detail-card {
        max-width: 100% !important;
    }

    /* ── CHAT MODAL ──────────────────────────────────────────────────────── */
    .chat-modal-card {
        height: 92dvh !important;
        max-height: 92dvh !important;
    }

    /* ── ORDERS / SALES MODALS ───────────────────────────────────────────── */
    #orders-modal .modal-card,
    #sales-modal .modal-card {
        max-width: 100% !important;
        width: 100% !important;
    }

    .modal-tabs {
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        flex-wrap: nowrap;
    }
    .modal-tabs::-webkit-scrollbar { display: none; }

    /* ── PURCHASE MODAL ──────────────────────────────────────────────────── */
    #purchase-modal .modal-card {
        max-width: 100% !important;
    }

    /* ── MODAL FORM ──────────────────────────────────────────────────────── */
    .modal-form .form-group {
        margin-bottom: 0.85rem;
    }

    .modal-title {
        font-size: 1.25rem !important;
    }

    .modal-subtitle {
        font-size: 0.85rem !important;
    }

    /* Botón cerrar modal: más fácil de pulsar en táctil */
    .modal-close {
        width: 36px;
        height: 36px;
        top: 16px;
        right: 16px;
    }

    /* ── CART DRAWER ─────────────────────────────────────────────────────── */
    /* Ya tiene max-width: 100vw en index.css a 480px */
    /* Aseguramos padding correcto */
    .cart-drawer {
        padding-bottom: calc(1.5rem + var(--safe-bot));
    }

    /* ── NOTIF PANEL ─────────────────────────────────────────────────────── */
    .notif-panel {
        right: -10px;
        width: calc(100vw - 2rem);
        max-width: 340px;
    }

    /* ── PERFIL MODAL ────────────────────────────────────────────────────── */
    .avatar-picker-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 0.5rem !important;
    }

    /* ── TOASTS ──────────────────────────────────────────────────────────── */
    /* Los toasts usan estilos inline, así que los sobrescribimos por clase */
    .binnder-toast {
        right: 12px !important;
        left: 12px !important;
        max-width: none !important;
        width: calc(100vw - 24px) !important;
        font-size: 0.85rem !important;
        padding: 0.8rem 1rem !important;
        border-radius: 14px !important;
    }

    /* ── CARD ZOOM OVERLAY ───────────────────────────────────────────────── */
    .card-zoom-overlay img {
        max-width: 90vw;
        max-height: 70vh;
    }

    /* ── GLASS PANEL ─────────────────────────────────────────────────────── */
    .glass-panel {
        padding: 1.25rem;
        border-radius: 18px;
    }

    /* ── ESTADOS VACÍOS ──────────────────────────────────────────────────── */
    .empty-state-container {
        padding: 2rem 1rem !important;
    }

    /* ── COLECCIÓN BLOQUEADA ─────────────────────────────────────────────── */
    .collection-locked {
        margin: 3rem 1.25rem !important;
        padding: 2rem 1.5rem !important;
    }

    /* ── TRADES CTA ──────────────────────────────────────────────────────── */
    .market-section {
        padding: 0 1.25rem;
        grid-template-columns: 1fr;
    }

    /* ── ADMIN MODAL ─────────────────────────────────────────────────────── */
    .admin-modal-card {
        max-width: 100% !important;
    }

    /* ── OFFER MODAL ─────────────────────────────────────────────────────── */
    .offer-modal-card {
        max-width: 100% !important;
    }

    /* ── SHARE COLLECTION MODAL ──────────────────────────────────────────── */
    #share-collection-modal .modal-card {
        max-width: 100% !important;
    }

} /* fin @media 768px */

/* ==========================================================================
   PANTALLAS MUY PEQUEÑAS (iPhone SE, < 390px)
   ========================================================================== */
@media (max-width: 390px) {

    .hero-title { font-size: 1.7rem; }

    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.55rem;
    }

    .tcg-card-img-container { height: 145px; }

    .tcg-filter-card {
        width: 84px;
        height: 120px;
    }

    .tfc-icon { font-size: 1.3rem; }
    .tfc-name { font-size: 0.72rem; }

    .mobile-tab {
        font-size: 0.6rem;
    }

    .mobile-upload-btn {
        width: 44px;
        height: 44px;
    }

    .game-chip {
        font-size: 0.75rem;
        padding: 0.75rem 0.6rem;
    }

} /* fin @media 390px */
