/*
 * CSS Responsivo personalizado para el proyecto
 * Optimizado para dispositivos móviles
 */

/* Estilos base para móviles */
@media (max-width: 768px) {
    /* Contenedor principal */
    .content-page {
        padding: 10px !important;
        margin-left: 0 !important;
    }
    
    .content {
        padding: 10px !important;
    }
    
    /* Tablas responsivas */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
        overflow-y: auto;
        border: 1px solid #ddd;
        border-radius: 4px;
        max-height: 70vh; /* Altura máxima para scroll vertical */
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .table {
        font-size: 12px;
        white-space: nowrap;
        margin-bottom: 0;
        min-width: 600px; /* Ancho mínimo para forzar scroll horizontal */
    }
    
    .table th,
    .table td {
        padding: 8px !important;
        vertical-align: middle;
        border: 1px solid #dee2e6;
    }
    
    /* Encabezados fijos en tablas largas */
    .table-responsive .table thead th {
        position: sticky;
        top: 0;
        background-color: #f8f9fa;
        z-index: 10;
        box-shadow: 0 2px 2px rgba(0,0,0,0.1);
    }
    
    /* Botones en móviles */
    .btn {
        font-size: 12px;
        padding: 6px 12px;
        margin: 2px;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        width: 100%;
        margin-bottom: 5px;
    }
    
    /* Formularios */
    .form-group {
        margin-bottom: 15px;
    }
    
    .form-control {
        font-size: 16px; /* Evita zoom en iOS */
        height: auto;
        padding: 10px 12px;
    }
    
    .form-row .col-md-6,
    .form-row .col-md-4,
    .form-row .col-md-3 {
        margin-bottom: 15px;
    }
    
    /* Cards responsivas */
    .card {
        margin-bottom: 15px;
    }
    
    .card-header {
        padding: 10px 15px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    /* Modal en móviles */
    .modal-dialog {
        margin: 10px;
        width: calc(100% - 20px);
        max-width: none;
    }
    
    /* DataTables en móviles */
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length {
        text-align: center;
        margin-bottom: 10px;
    }
    
    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        max-width: 200px;
    }
    
    /* Ocultar columnas menos importantes en móviles */
    .table .d-none-mobile {
        display: none !important;
    }
    
    /* Navegación móvil */
    .topbar {
        position: relative;
        z-index: 1000;
    }
    
    .navbar-custom {
        padding: 0 10px;
    }
    
    /* Footer responsivo */
    .footer {
        padding: 15px 20px;
        text-align: center;
    }
    
    /* Utilidades móviles */
    .text-mobile-center {
        text-align: center !important;
    }
    
    .mb-mobile-3 {
        margin-bottom: 1rem !important;
    }
    
    .p-mobile-2 {
        padding: 0.5rem !important;
    }
    
    /* Stack de elementos en móvil */
    .mobile-stack {
        flex-direction: column !important;
    }
    
    .mobile-stack > * {
        width: 100% !important;
        margin-bottom: 10px;
    }
    
    /* Texto más pequeño en móviles */
    .mobile-small-text {
        font-size: 12px;
    }
    
    /* Ocultar elementos en móvil */
    .d-mobile-none {
        display: none !important;
    }
}

/* Estilos para tablets */
@media (min-width: 769px) and (max-width: 1024px) {
    .table {
        font-size: 13px;
    }
    
    .btn {
        font-size: 13px;
    }
    
    .card-body {
        padding: 20px;
    }
}

/* Estilos para pantallas muy pequeñas */
@media (max-width: 480px) {
    .content-page {
        padding: 5px !important;
    }
    
    .content {
        padding: 5px !important;
    }
    
    .table {
        font-size: 11px;
    }
    
    .table th,
    .table td {
        padding: 4px !important;
    }
    
    .btn {
        font-size: 11px;
        padding: 4px 8px;
    }
    
    .card-body {
        padding: 10px;
    }
    
    .form-control {
        padding: 8px 10px;
    }
    
    /* Título más pequeño en pantallas muy pequeñas */
    h1, .h1 { font-size: 1.5rem; }
    h2, .h2 { font-size: 1.3rem; }
    h3, .h3 { font-size: 1.1rem; }
    h4, .h4 { font-size: 1rem; }
}

/* Mejoras específicas para formularios */
@media (max-width: 768px) {
    select.form-control {
        background-size: 16px 12px;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .input-group .form-control,
    .input-group-append .btn,
    .input-group-prepend .btn {
        border-radius: 4px !important;
        margin-bottom: 5px;
    }
    
    .input-group-append,
    .input-group-prepend {
        width: 100%;
    }
}

/* Mejoras para DataTables en móvil */
@media (max-width: 768px) {
    .dataTables_wrapper {
        overflow: visible;
    }
    
    .dataTables_wrapper .dataTables_scrollBody {
        overflow-x: auto !important;
        overflow-y: auto !important;
        max-height: 60vh;
        border: 1px solid #dee2e6;
        border-radius: 4px;
    }
    
    .dataTables_wrapper .dataTables_paginate {
        text-align: center;
        margin-top: 10px;
        overflow-x: auto;
        padding: 5px;
    }
    
    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 5px 8px;
        margin: 0 2px;
        min-width: 35px;
        font-size: 12px;
    }
    
    .dataTables_wrapper .dataTables_info {
        text-align: center;
        font-size: 12px;
        padding: 5px;
    }
    
    .dataTables_wrapper .dataTables_filter {
        margin-bottom: 10px;
    }
    
    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        max-width: 200px;
        margin-left: 5px;
    }
    
    .dataTables_wrapper .dataTables_length {
        margin-bottom: 10px;
    }
    
    /* Indicadores visuales para scroll en DataTables */
    .dataTables_scrollBody.has-scroll {
        position: relative;
    }
    
    .dataTables_scrollBody.can-scroll-right::after {
        content: "→";
        position: absolute;
        right: 5px;
        top: 50%;
        transform: translateY(-50%);
        background: rgba(0,123,255,0.8);
        color: white;
        border-radius: 50%;
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        z-index: 10;
        pointer-events: none;
    }
    
    .dataTables_scrollBody.scrolled-left::before {
        content: "←";
        position: absolute;
        left: 5px;
        top: 50%;
        transform: translateY(-50%);
        background: rgba(0,123,255,0.8);
        color: white;
        border-radius: 50%;
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        z-index: 10;
        pointer-events: none;
    }
}

/* Mejoras para el menú lateral */
@media (max-width: 768px) {
    .side-menu {
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
    }
    
    .side-menu.active {
        transform: translateX(0);
    }
    
    .side-menu ul li a {
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* Mejoras para alertas y notificaciones */
@media (max-width: 768px) {
    .alert {
        padding: 10px 15px;
        font-size: 13px;
        margin-bottom: 10px;
    }
    
    .alert .close {
        padding: 10px 15px;
    }
}

/* Mejoras para badges y etiquetas */
@media (max-width: 768px) {
    .badge {
        font-size: 10px;
        padding: 3px 6px;
    }
}

/* Scrollbar personalizado para móviles */
@media (max-width: 768px) {
    .table-responsive::-webkit-scrollbar {
        height: 8px;
        width: 8px;
    }
    
    .table-responsive::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 4px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb {
        background: #007bff;
        border-radius: 4px;
    }
    
    .table-responsive::-webkit-scrollbar-thumb:hover {
        background: #0056b3;
    }
    
    .table-responsive::-webkit-scrollbar-corner {
        background: #f1f1f1;
    }
    
    /* Indicadores visuales de scroll */
    .table-responsive.has-scroll {
        position: relative;
    }
    
    .table-responsive.has-scroll::before {
        content: "← Desliza horizontalmente para ver más →";
        display: block;
        text-align: center;
        font-size: 11px;
        color: #6c757d;
        background: #f8f9fa;
        padding: 5px;
        border-bottom: 1px solid #dee2e6;
        position: sticky;
        top: 0;
        z-index: 15;
    }
    
    .table-responsive.can-scroll-right::after {
        content: "→";
        position: absolute;
        right: 5px;
        top: 50%;
        transform: translateY(-50%);
        background: rgba(0,123,255,0.8);
        color: white;
        border-radius: 50%;
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        z-index: 10;
        pointer-events: none;
        animation: pulse 2s infinite;
    }
    
    .table-responsive.scrolled-left::before {
        content: "←";
        position: absolute;
        left: 5px;
        top: 50%;
        transform: translateY(-50%);
        background: rgba(0,123,255,0.8);
        color: white;
        border-radius: 50%;
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 12px;
        z-index: 10;
        pointer-events: none;
    }
    
    /* Ocultar indicador de texto cuando no hay scroll */
    .table-responsive.no-scroll::before {
        display: none;
    }
    
    /* Animación para el indicador de scroll */
    @keyframes pulse {
        0% { opacity: 1; }
        50% { opacity: 0.5; }
        100% { opacity: 1; }
    }
}