/* ========================================
   VIDEO MARKETPLACE v2 - MOBILE IMPROVEMENTS v6.4.0
   Mejoras para experiencia móvil optimizada
   ======================================== */

/* ========================================
   MEJORAS GLOBALES MÓVIL
   ======================================== */

@media (max-width: 768px) {
    /* Prevenir zoom en iOS - TODOS los inputs >= 16px */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    input[type="search"],
    input[type="url"],
    textarea,
    select,
    .vme-input,
    .vme-buyer-input {
        /* font-size controlled by theme */
        -webkit-appearance: none;
        appearance: none;
    }
    
    /* Labels más legibles */
    label,
    .vme-form-label,
    .vme-buyer-form-label {
        /* font-size controlled by theme */
        font-weight: 500;
    }
    
    /* Botones con touch target adecuado (mínimo 44px) */
    body.vme-active .vme-btn,
body.vme-active .vme-buyer-btn,
body.vme-active button[type="submit"],
body.vme-active button[type="button"],
body.vme-active .vme-button {
        min-height: 48px;
        padding: 14px 20px;
        /* font-size controlled by theme */
        font-weight: 600;
    }
    
    /* Links y elementos clickeables */
    a,
    .vme-link {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}

/* ========================================
   DASHBOARD COMPRADORES - BOTTOM NAV
   ======================================== */

@media (max-width: 768px) {
    body.vme-active .vme-buyer-nav {
        height: 68px; /* Aumentado de 65px */
        position: relative;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .vme-buyer-nav::-webkit-scrollbar {
        display: none;
    }
    
    /* Gradientes indicadores de scroll */
    .vme-buyer-nav::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        width: 40px;
        height: 100%;
        background: linear-gradient(to left, var(--buyer-red-600) 0%, transparent 100%);
        pointer-events: none;
        z-index: 1;
    }
    
    .vme-buyer-nav.scrolled::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        width: 40px;
        height: 100%;
        background: linear-gradient(to right, var(--buyer-red-600) 0%, transparent 100%);
        pointer-events: none;
        z-index: 1;
    }
    
    body.vme-active .vme-buyer-nav-item {
        padding: 12px 8px;
        gap: 5px;
        min-width: 75px;
    }
    
    .vme-buyer-nav-item i {
        /* font-size controlled by theme */ /* Aumentado de 18px */
    }
    
    .vme-buyer-nav-item span {
        /* font-size controlled by theme */ /* Aumentado de 10px */
        font-weight: 500;
    }
    
    /* Indicador visual de item activo */
    .vme-buyer-nav-item.active::after {
        content: '';
        position: absolute;
        bottom: -3px;
        left: 50%;
        transform: translateX(-50%);
        width: 6px;
        height: 6px;
        background: #fff;
        border-radius: 50%;
        box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
    }
    
    /* Ripple effect */
    .vme-buyer-nav-item:active {
        background: rgba(0, 0, 0, 0.25);
        transform: scale(0.98);
        transition: all 0.1s;
    }
    
    body.vme-active .vme-buyer-main {
        margin-bottom: 68px;
    }
    
    .vme-buyer-section {
        padding-bottom: 30px;
    }
}

@media (max-width: 480px) {
    .vme-buyer-nav-item i {
        /* font-size controlled by theme */
    }
    
    .vme-buyer-nav-item span {
        /* font-size controlled by theme */
    }
}

/* ========================================
   DASHBOARD CREADORES - BOTTOM NAV
   ======================================== */

@media (max-width: 768px) {
    body.vme-active .vme-sidebar {
        height: auto;
    }
    
    body.vme-active .vme-sidebar-nav {
        height: 68px;
        position: relative;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .vme-sidebar-nav::-webkit-scrollbar {
        display: none;
    }
    
    /* Gradientes indicadores */
    .vme-sidebar-nav::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        width: 40px;
        height: 100%;
        background: linear-gradient(to left, var(--creator-red) 0%, transparent 100%);
        pointer-events: none;
        z-index: 1;
    }
    
    .vme-sidebar-nav.scrolled::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        width: 40px;
        height: 100%;
        background: linear-gradient(to right, var(--creator-red) 0%, transparent 100%);
        pointer-events: none;
        z-index: 1;
    }
    
    body.vme-active .vme-nav-item {
        padding: 12px 8px;
        gap: 5px;
        min-width: 75px;
    }
    
    .vme-nav-item i {
        /* font-size controlled by theme */
    }
    
    .vme-nav-item span {
        /* font-size controlled by theme */
        font-weight: 500;
    }
    
    .vme-nav-item.active::after {
        content: '';
        position: absolute;
        bottom: -3px;
        left: 50%;
        transform: translateX(-50%);
        width: 6px;
        height: 6px;
        background: #D73744;
        border-radius: 50%;
        box-shadow: 0 0 8px rgba(215, 55, 68, 0.5);
    }
    
    .vme-nav-item:active {
        background: rgba(0, 0, 0, 0.25);
        transform: scale(0.98);
        transition: all 0.1s;
    }
    
    body.vme-active .vme-main-content {
        margin-bottom: 68px;
    }
    
    .vme-section {
        padding-bottom: 30px;
    }
}

@media (max-width: 480px) {
    .vme-nav-item i {
        /* font-size controlled by theme */
    }
    
    .vme-nav-item span {
        /* font-size controlled by theme */
    }
}

/* ========================================
   CHECKOUT - CAMPOS YAPE
   ======================================== */

@media (max-width: 768px) {
    /* CRÍTICO: Campos Yape grandes y tocables */
    body.vme-active .vme-yape-code-digit,
body.vme-active .vme-yape-code-input,
body.vme-active input[name^="yape_code"],
body.vme-active .yape-digit-input {
        width: 65px;
        height: 65px;
        /* font-size controlled by theme */
        border: 2px solid #ddd;
        border-radius: 10px;
        text-align: center;
        /* font-weight controlled by theme */
    }
    
    body.vme-active .vme-yape-code-digit:focus,
body.vme-active .vme-yape-code-input:focus,
body.vme-active input[name^="yape_code"]:focus {
        border-color: #D73744;
        box-shadow: 0 0 0 3px rgba(215, 55, 68, 0.2);
        outline: none;
    }
    
    body.vme-active .vme-yape-code-container {
        gap: 12px;
        justify-content: center;
        padding: 20px 10px;
        display: flex;
    }
}

@media (max-width: 480px) {
    body.vme-active .vme-yape-code-digit,
body.vme-active .vme-yape-code-input,
body.vme-active input[name^="yape_code"] {
        width: 58px;
        height: 58px;
        /* font-size controlled by theme */
    }
    
    body.vme-active .vme-yape-code-container {
        gap: 10px;
    }
}

/* ========================================
   TABLAS → CARDS EN MÓVIL
   ======================================== */

@media (max-width: 768px) {
    /* Ocultar tablas tradicionales */
    body.vme-active .vme-table-responsive table,
body.vme-active .vme-videos-table,
body.vme-active .vme-sales-table,
body.vme-active .vme-buyer-purchase-table {
        display: block;
    }
    
    /* Mostrar versión cards */
    body.vme-active .vme-mobile-cards {
        display: block;
    }
}

/* Cards móviles */
.vme-mobile-cards {
    display: none;
}

.vme-mobile-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s;
}

.vme-mobile-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.vme-mobile-card-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.vme-mobile-card-thumbnail {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.vme-mobile-card-info {
    flex: 1;
    min-width: 0;
}

.vme-mobile-card-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0 0 5px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.vme-mobile-card-meta {
    font-size: 13px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 8px;
}

.vme-mobile-card-body {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 15px;
}

.vme-mobile-card-stat {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
}

.vme-mobile-card-stat-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
    font-weight: 500;
}

.vme-mobile-card-stat-value {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.vme-mobile-card-actions {
    display: flex;
    gap: 8px;
}

.vme-mobile-card-btn {
    flex: 1;
    padding: 12px 8px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 48px;
}

.vme-mobile-card-btn.primary {
    background: #D73744;
    color: white;
}

.vme-mobile-card-btn.secondary {
    background: #f0f0f0;
    color: #333;
}

.vme-mobile-card-btn:active {
    transform: scale(0.95);
}

/* ========================================
   CATÁLOGO PÚBLICO
   ======================================== */

@media (max-width: 768px) {
    /* Video preview con tap (no solo hover) */
    body.vme-active .vme-public-video-card.touch-active .vme-video-preview {
        opacity: 1;
        z-index: 2;
    }
    
    /* Botón play más visible */
    body.vme-active .vme-video-play-btn {
        width: 70px;
        height: 70px;
        background: rgba(255, 255, 255, 0.95);
        color: #D73744;
        border-radius: 50%;
        /* font-size controlled by theme */
    }
}

/* ========================================
   MODALES OPTIMIZADOS
   ======================================== */

@media (max-width: 768px) {
    body.vme-active .vme-modal {
        padding: 0;
        align-items: flex-start;
    }
    
    body.vme-active .vme-modal-content {
        width: 100%;
        max-width: none;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
        overflow-y: auto;
        padding: 20px 16px;
    }
    
    .vme-modal-header {
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
        padding-bottom: 15px;
        margin-bottom: 20px;
        border-bottom: 1px solid #eee;
    }
    
    .vme-modal-title {
        /* font-size controlled by theme */
    }
    
    body.vme-active .vme-modal-close {
        width: 44px;
        height: 44px;
        /* font-size controlled by theme */
        min-width: 44px;
        min-height: 44px;
    }
    
    body.vme-active .vme-modal-body {
        padding: 0;
    }
    
    .vme-modal-footer {
        position: sticky;
        bottom: 0;
        background: white;
        padding-top: 15px;
        margin-top: 20px;
        border-top: 1px solid #eee;
        display: flex;
        gap: 10px;
    }
    
    body.vme-active .vme-modal-footer .vme-btn {
        flex: 1;
        min-height: 52px;
        /* font-size controlled by theme */
    }
    
    /* Upload area más grande */
    body.vme-active .vme-upload-area {
        min-height: 200px;
        padding: 30px 20px;
    }
}

/* ========================================
   LAZY LOADING
   ======================================== */

img.lazyload {
    opacity: 0;
    transition: opacity 0.3s;
}

img.lazyloaded {
    opacity: 1;
}

/* ========================================
   RIPPLE EFFECT
   ======================================== */

.vme-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    width: 20px;
    height: 20px;
    margin-left: -10px;
    margin-top: -10px;
    animation: ripple-animation 0.6s;
    pointer-events: none;
}

@keyframes ripple-animation {
    from {
        transform: scale(0);
        opacity: 1;
    }
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */

@media (max-width: 768px) {
    /* Transiciones suaves entre secciones */
    .vme-section,
    .vme-buyer-section {
        transition: opacity 0.3s ease, transform 0.3s ease;
    }
    
    .vme-section:not(.active),
    .vme-buyer-section:not(.active) {
        opacity: 1;
        transform: translateX(0);
    }
    
    .vme-section.active,
    .vme-buyer-section.active {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========================================
   UTILITIES MÓVIL
   ======================================== */

@media (max-width: 768px) {
    /* Ocultar solo en móvil */
    body.vme-active .hide-mobile {
        display: none;
    }
    
    /* Mostrar solo en móvil */
    body.vme-active .show-mobile {
        display: block;
    }
    
    /* Stack vertical en móvil */
    body.vme-active .mobile-stack {
        flex-direction: column;
    }
    
    /* Full width en móvil */
    body.vme-active .mobile-full {
        width: 100%;
    }
    
    /* Texto centrado en móvil */
    body.vme-active .mobile-center {
        text-align: center;
    }
}

/* Desktop: ocultar elementos mobile-only */
@media (min-width: 769px) {
    body.vme-active .show-mobile {
        display: none;
    }
}

/* ========================================
   ACCESIBILIDAD MEJORADA
   ======================================== */

@media (max-width: 768px) {
    /* Focus visible en elementos interactivos */
    a:focus,
    button:focus,
    input:focus,
    select:focus,
    textarea:focus,
    .vme-nav-item:focus,
    .vme-buyer-nav-item:focus {
        outline: 3px solid #D73744;
        outline-offset: 2px;
    }
    
    /* Skip to content para lectores de pantalla */
    .skip-to-content {
        position: absolute;
        top: -40px;
        left: 0;
        background: #D73744;
        color: white;
        padding: 12px;
        text-decoration: none;
        z-index: 100;
    }
    
    .skip-to-content:focus {
        top: 0;
    }
}

/* ========================================
   PERFORMANCE
   ======================================== */

@media (max-width: 768px) {
    /* Hardware acceleration para animaciones */
    .vme-nav-item,
    .vme-buyer-nav-item,
    .vme-mobile-card,
    .vme-btn,
    .vme-modal-content {
        transform: translateZ(0);
        backface-visibility: hidden;
        -webkit-font-smoothing: subpixel-antialiased;
    }
    
    /* Smooth scrolling nativo */
    html {
        scroll-behavior: smooth;
    }
    
    body {
        -webkit-overflow-scrolling: touch;
    }
}

/* ========================================
   FIN DE MEJORAS MÓVILES v6.4.0
   ======================================== */

/* ========================================
   v6.4.1 - FIX VIDEO NAVIGATION MOBILE
   ======================================== */

@media (max-width: 768px) {
    /* Indicador visual cuando preview está activo */
    .vme-public-video-card.preview-playing {
        border: 3px solid #D73744;
        box-shadow: 0 0 20px rgba(215, 55, 68, 0.4);
    }
    
    /* Hint de preview */
    .vme-preview-hint {
        display: block;
        animation: slideInDown 0.5s ease-out;
    }
    
    @keyframes slideInDown {
        from {
            opacity: 0;
            transform: translateY(-20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    /* Asegurar que links sean clickeables */
    .vme-public-video-card-link {
        display: block;
        text-decoration: none;
        color: inherit;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
    
    /* Touch feedback en card */
    .vme-public-video-card {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    .vme-public-video-card:active:not(.preview-playing) {
        transform: scale(0.98);
        transition: transform 0.1s;
    }
}

/* Desktop: ocultar hint */
@media (min-width: 769px) {
    body.vme-active .vme-preview-hint {
        display: none;
    }
}

/* ========================================
   FIN FIX v6.4.1
   ======================================== */

/* ========================================
   v6.4.2 - EMERGENCY FIX BOTTOM NAV
   ======================================== */

@media (max-width: 768px) {
    /* FORZAR bottom navigation visible */
    body .vme-sidebar,
body.logged-in .vme-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
        height: 68px;
        z-index: 9999;
        transform: translateX(0);
        display: block;
        visibility: visible;
        opacity: 1;
        /* CRÍTICO: Colores correctos */
        background: #D73744; /* Rojo HotMe */
        background-color: #D73744;
        background-image: none;
    }
    
    /* FORZAR navegación horizontal */
    body .vme-sidebar-nav,
body.logged-in .vme-sidebar-nav {
        display: flex;
        flex-direction: row;
        height: 68px;
        position: relative;
        transform: none;
        visibility: visible;
        background: transparent;
    }
    
    /* FORZAR colores de items (excepto active) */
    body .vme-nav-item:not(.active),
body.logged-in .vme-nav-item:not(.active) {
        color: #ffffff; /* Texto blanco */
        background: transparent;
        background-color: transparent;
        background-image: none;
    }
    
    /* FORZAR color de iconos (excepto active) */
    body .vme-nav-item:not(.active) i,
body.logged-in .vme-nav-item:not(.active) i {
        color: #ffffff; /* Iconos blancos */
    }
    
    /* FORZAR color de texto (excepto active) */
    body .vme-nav-item:not(.active) span,
body.logged-in .vme-nav-item:not(.active) span {
        color: #ffffff; /* Texto blanco */
    }
    
    /* Item activo - fondo blanco con texto rojo */
    body .vme-nav-item.active,
body.logged-in .vme-nav-item.active {
        background: #ffffff;
        background-color: #ffffff;
        background-image: none;
        border-bottom: 3px solid #D73744;
        color: #D73744;
    }
    
    body .vme-nav-item.active i,
body.logged-in .vme-nav-item.active i {
        color: #D73744;
    }
    
    body .vme-nav-item.active span,
body.logged-in .vme-nav-item.active span {
        color: #D73744;
    }
    
    /* Item hover */
    body .vme-nav-item:hover,
body.logged-in .vme-nav-item:hover {
        background: rgba(0, 0, 0, 0.15);
        background-color: rgba(0, 0, 0, 0.15);
        background-image: none;
    }
    
    /* FORZAR ocultar header/footer */
    body .vme-sidebar-header,
body .vme-sidebar-footer {
        display: none;
        visibility: hidden;
    }
    
    /* FORZAR espaciado en main content */
    body .vme-main-content,
body.logged-in .vme-main-content {
        margin-left: 0;
        margin-bottom: 80px;
        padding-bottom: 30px;
    }
    
    /* FORZAR espaciado en secciones */
    body .vme-section,
body #section-perfil {
        padding-bottom: 40px;
        margin-bottom: 20px;
    }
    
    /* Asegurar que botón guardar no quede oculto */
    body .vme-btn-primary,
body button[type="submit"] {
        margin-bottom: 30px;
    }
}

/* Desktop - asegurar que no afecte */
@media (min-width: 769px) {
    body .vme-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: auto;
        right: auto;
        width: 280px;
        height: 100vh;
        z-index: 100;
    }
}
