/**
 * Mobile Optimizations para iPhone y dispositivos móviles
 * Añadir este CSS al layout principal
 */

/* ==============================================
   MEJORAS GENERALES PARA MÓVIL
   ============================================== */

/* Asegurar que todo el texto sea legible en móvil */
body {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Botones táctiles más grandes (mínimo 44x44px según Apple HIG) */
.btn {
    min-height: 44px;
    padding: 0.5rem 1rem;
}

.btn-sm {
    min-height: 38px;
    padding: 0.4rem 0.8rem;
}

.btn-lg {
    min-height: 50px;
    padding: 0.75rem 1.5rem;
}

/* Enlaces táctiles más grandes */
a:not(.btn) {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

/* Inputs y formularios más grandes para toque */
.form-control,
.form-select {
    min-height: 44px;
    font-size: 16px; /* Evita zoom automático en iPhone */
}

/* ==============================================
   MOBILE-SPECIFIC RESPONSIVE FIXES
   ============================================== */

@media (max-width: 991.98px) {
    /* Stats cards en móvil - stack verticalmente */
    .stat-card {
        margin-bottom: 1rem;
    }

    .stat-value {
        font-size: 2rem !important;
    }

    /* Charts más pequeños en móvil */
    .chart-container {
        height: 250px !important;
    }

    /* Tablas responsivas - scroll horizontal */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    /* Navbar user info oculto en móvil */
    .navbar .text-white-50 {
        display: none !important;
    }

    /* Week info banner responsive */
    .week-info {
        text-align: center;
    }

    .week-info .row > div {
        margin-bottom: 0.5rem;
    }

    /* Modal full-width en móvil */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    /* Checkout modal específico */
    #checkoutModal .modal-dialog {
        margin: 1rem 0.5rem;
    }

    #checkout-course-image {
        width: 50px !important;
        height: 50px !important;
    }

    .stat-label {
        font-size: 0.75rem;
    }
}

@media (max-width: 575.98px) {
    /* Extra small devices */
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .stat-value {
        font-size: 1.75rem !important;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    /* Botones full-width en muy pequeño */
    .btn-block-mobile {
        display: block;
        width: 100%;
    }

    /* Cards con menos padding */
    .card-body {
        padding: 1rem;
    }

    /* Navbar brand más pequeño */
    .navbar-brand {
        font-size: 1rem;
    }
}

/* ==============================================
   CHECKOUT MODAL OPTIMIZATIONS
   ============================================== */

/* Mejorar legibilidad del modal de checkout */
#checkoutModal .modal-title {
    font-size: 1.1rem;
}

#checkoutModal .modal-body {
    padding: 1rem;
}

#checkoutModal .modal-footer {
    padding: 1rem;
    flex-direction: column;
    gap: 0.5rem;
}

@media (max-width: 575.98px) {
    #checkoutModal .modal-footer .btn {
        width: 100%;
    }

    #checkout-price-mxn {
        font-size: 1.25rem !important;
    }
}

/* ==============================================
   STRIPE PAYMENT ELEMENT MOBILE
   ============================================== */

#payment-element {
    min-height: 200px;
}

/* Asegurar que Stripe Elements sean táctiles */
#payment-element iframe {
    min-height: 200px;
}

/* ==============================================
   TABLAS RESPONSIVE
   ============================================== */

@media (max-width: 991.98px) {
    /* Hacer tablas scrolleables */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    /* Reducir padding de celdas */
    .table td,
    .table th {
        padding: 0.5rem 0.25rem;
        font-size: 0.875rem;
    }
}

/* ==============================================
   NAVBAR MOBILE IMPROVEMENTS
   ============================================== */

/* Asegurar que el toggler sea visible y táctil */
.navbar-toggler {
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25);
}

/* Menú móvil con mejor espaciado */
@media (max-width: 991.98px) {
    .navbar-collapse {
        margin-top: 1rem;
        padding: 1rem 0;
        background: rgba(0, 0, 0, 0.1);
        border-radius: 0.5rem;
    }

    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        border-radius: 0.25rem;
    }

    .navbar-nav .nav-link:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    /* Form de logout full-width en móvil */
    .navbar-collapse form {
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .navbar-collapse form .btn {
        width: 100%;
    }
}

/* ==============================================
   COURSE CARDS MOBILE
   ============================================== */

@media (max-width: 767.98px) {
    /* Course cards stack en móvil */
    .course-card {
        margin-bottom: 1.5rem;
    }

    .course-card img {
        max-height: 200px;
        object-fit: cover;
    }

    .course-card .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* ==============================================
   LESSON VIEWER MOBILE
   ============================================== */

@media (max-width: 991.98px) {
    /* Video responsive */
    .lesson-video {
        width: 100%;
        height: auto;
        aspect-ratio: 16/9;
    }

    /* Sidebar de navegación oculto en móvil */
    .lesson-sidebar {
        display: none;
    }

    /* Botones de navegación full-width */
    .lesson-navigation {
        flex-direction: column;
        gap: 0.5rem;
    }

    .lesson-navigation .btn {
        width: 100%;
    }
}

/* ==============================================
   SAFE AREA INSETS (iPhone X+)
   ============================================== */

/* Soporte para notch y bottom bar de iPhone */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .navbar {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    .modal-dialog {
        margin-left: max(0.5rem, env(safe-area-inset-left));
        margin-right: max(0.5rem, env(safe-area-inset-right));
    }
}

/* ==============================================
   SCROLL BEHAVIOR
   ============================================== */

/* Smooth scrolling en iOS */
html {
    -webkit-overflow-scrolling: touch;
}

/* Prevenir zoom en inputs */
@media (max-width: 575.98px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* ==============================================
   LOADING STATES
   ============================================== */

/* Spinners más visibles en móvil */
.spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

.spinner-border-sm {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 0.2rem;
}

/* ==============================================
   TOAST/ALERTS MOBILE
   ============================================== */

@media (max-width: 575.98px) {
    .alert {
        font-size: 0.875rem;
        padding: 0.75rem;
    }

    /* SweetAlert2 mobile */
    .swal2-popup {
        font-size: 0.875rem;
        padding: 1.5rem;
    }

    .swal2-title {
        font-size: 1.25rem;
    }
}

/* ==============================================
   BADGE IMPROVEMENTS
   ============================================== */

.badge {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
}

@media (max-width: 575.98px) {
    .badge {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }
}
