﻿/* ===================================
   SPI PRODUCCIÓN - MOVIL.CSS
   Optimizaciones para dispositivos móviles
   =================================== */

/* BASE MOBILE
----------------------------------------------------------*/

body {
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    padding: 0;
    color: #495057;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* TOUCH OPTIMIZATION
----------------------------------------------------------*/

/* Aumentar área de toque para mejor UX móvil */
button,
a,
.btn,
.nav-link,
.dropdown-item {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Prevenir zoom en inputs en iOS */
input[type="text"],
input[type="email"],
input[type="number"],
input[type="tel"],
select,
textarea {
    font-size: 16px !important;
}

/* RESPONSIVE CONTAINERS
----------------------------------------------------------*/

@media (max-width: 576px) {
    .container,
    .container-fluid {
        padding-right: 10px;
        padding-left: 10px;
    }

    /* Reducir padding en móviles */
    .py-4 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}

/* NAVBAR MOBILE
----------------------------------------------------------*/

@media (max-width: 991px) {
    .navbar-collapse {
        background-color: #212529;
        margin-top: 0.5rem;
        padding: 1rem;
        border-radius: 0.375rem;
    }

    .navbar-nav {
        margin-top: 0.5rem;
    }

        .navbar-nav .nav-link {
            padding: 0.75rem 1rem !important;
            border-bottom: 1px solid rgba(255,255,255,0.1);
        }

            .navbar-nav .nav-link:last-child {
                border-bottom: none;
            }
}

/* FORMS MOBILE
----------------------------------------------------------*/

@media (max-width: 767px) {
    /* Stack de formularios vertical en móvil */
    .form-group .row > div {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    label.control-label {
        text-align: left !important;
        padding-right: 0;
        margin-bottom: 0.25rem;
        font-size: 0.9rem;
    }

    .form-control,
    .form-select {
        width: 100%;
    }

    /* Botones en columna en móvil */
    .btn-group,
    .btn-toolbar {
        flex-direction: column;
        width: 100%;
    }

        .btn-group > .btn,
        .btn-toolbar > .btn {
            width: 100%;
            margin-bottom: 0.5rem;
            margin-right: 0;
        }

    .row > div > .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* TABLES MOBILE
----------------------------------------------------------*/

@media (max-width: 767px) {
    /* Convertir tabla a cards en móvil */
    .table-responsive {
        border: none;
    }

    .table thead {
        display: none;
    }

    .table,
    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
    }

        .table tr {
            margin-bottom: 1rem;
            border: 1px solid #dee2e6;
            border-radius: 0.5rem;
            background: #fff;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        }

        .table td {
            text-align: left;
            padding: 0.75rem;
            border: none;
            position: relative;
            padding-left: 50%;
        }

            .table td:before {
                content: attr(data-label);
                position: absolute;
                left: 0.75rem;
                width: 45%;
                padding-right: 0.5rem;
                font-weight: 600;
                color: #495057;
                text-align: left;
            }

            .table td:first-child {
                background: #f8f9fa;
                font-weight: 600;
                border-top-left-radius: 0.5rem;
                border-top-right-radius: 0.5rem;
            }

            .table td:last-child {
                border-bottom-left-radius: 0.5rem;
                border-bottom-right-radius: 0.5rem;
            }
}

/* PAGINATION MOBILE
----------------------------------------------------------*/

@media (max-width: 576px) {
    .pagination {
        font-size: 0.875rem;
    }

    .page-link {
        padding: 0.5rem 0.75rem;
    }
}

/* MODALS MOBILE
----------------------------------------------------------*/

@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-content {
        border-radius: 0.5rem;
    }
}

/* DROPDOWNS MOBILE
----------------------------------------------------------*/

@media (max-width: 576px) {
    .dropdown-menu {
        width: 100%;
        max-width: none;
    }
}

/* CARDS & PANELS MOBILE
----------------------------------------------------------*/

@media (max-width: 767px) {
    .card {
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1rem;
    }
}

/* GRID ADJUSTMENTS MOBILE
----------------------------------------------------------*/

@media (max-width: 576px) {
    .row {
        margin-right: 0;
        margin-left: 0;
    }

        .row > * {
            padding-right: 0;
            padding-left: 0;
        }
}

/* TEXT RESPONSIVE
----------------------------------------------------------*/

@media (max-width: 576px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    h4, h5, h6 {
        font-size: 1rem;
    }

    p {
        font-size: 0.9rem;
    }
}

/* SPACING MOBILE
----------------------------------------------------------*/

@media (max-width: 576px) {
    .mt-5,
    .my-5 {
        margin-top: 2rem !important;
    }

    .mb-5,
    .my-5 {
        margin-bottom: 2rem !important;
    }

    .pt-5,
    .py-5 {
        padding-top: 1.5rem !important;
    }

    .pb-5,
    .py-5 {
        padding-bottom: 1.5rem !important;
    }
}

/* IMAGES RESPONSIVE
----------------------------------------------------------*/

img {
    max-width: 100%;
    height: auto;
}

/* LANDSCAPE ORIENTATION
----------------------------------------------------------*/

@media (max-width: 767px) and (orientation: landscape) {
    .navbar-brand img {
        max-height: 35px;
    }

    .py-4 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
}

/* SCROLL OPTIMIZATION
----------------------------------------------------------*/

/* Smooth scrolling en móvil */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Prevenir scroll horizontal */
body {
    overflow-x: hidden;
}

/* ACCESSIBILITY MOBILE
----------------------------------------------------------*/

/* Mejorar contraste en pantallas pequeñas */
@media (max-width: 576px) {
    .text-muted {
        color: #6c757d !important;
    }
}

/* Focus visible en móvil */
button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* PERFORMANCE OPTIMIZATIONS
----------------------------------------------------------*/

/* Hardware acceleration para animaciones */
.navbar-collapse,
.dropdown-menu,
.modal {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

/* Reducir animaciones en dispositivos lentos */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
