/* Mejoras de diseño responsive para FitCancer11 */

/* Base styles - mejoras generales */
body {
    font-size: 16px;
    line-height: 1.5;
    overflow-x: hidden;
}

.content-wrapper {
    width: 95%;
    max-width: 1200px;
    padding: 20px;
}

/* Mejoras para navegación en dispositivos móviles */
.nav-tabs {
    display: flex;
    flex-wrap: wrap;
}

.nav-tabs .nav-item {
    flex: 1 1 auto;
    text-align: center;
    min-width: 120px;
}

.nav-tabs .nav-link {
    padding: 10px 5px;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Media queries para diferentes tamaños de pantalla */
/* Tablets y pantallas medianas */
@media (max-width: 992px) {
    h1 {
        font-size: 1.8rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .stat-card {
        min-width: 160px;
        margin: 5px;
        padding: 10px;
    }
    
    .stat-value {
        font-size: 1.6rem;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    /* Ajuste para tablas */
    .table th, .table td {
        padding: 0.5rem;
    }
}

/* Smartphones y pantallas pequeñas */
@media (max-width: 767px) {
    body {
        font-size: 14px;
    }
    
    h1 {
        font-size: P1.5rem;
        margin-bottom: 0.5rem;
    }
    
    h2 {
        font-size: 1.3rem;
    }
    
    .content-wrapper {
        padding: 15px;
        margin: 15px auto;
    }
    
    /* Ajustes de tabs para móviles */
    .nav-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 5px;
    }
    
    .nav-tabs .nav-item {
        min-width: 100px;
    }
    
    .nav-tabs .nav-link {
        font-size: 0.8rem;
        padding: 8px 5px;
    }
    
    /* Ajustes para tablas en móvil */
    .table {
        font-size: 0.8rem;
    }
    
    .table th, .table td {
        padding: 0.4rem 0.3rem;
    }
    
    /* Ajustes para botones */
    .btn-export {
        padding: 6px 10px;
        font-size: 0.85rem;
    }
    
    /* Ajustes para tarjetas de estadísticas */
    .stats-container {
        flex-direction: column;
        align-items: center;
    }
    
    .stat-card {
        width: 100%;
        max-width: 300px;
        margin-bottom: 10px;
    }
    
    /* Ajustes para DataTables */
    .dataTables_filter, .dataTables_length {
        float: none;
        text-align: center;
        margin-bottom: 10px;
    }
    
    .dataTables_info, .dataTables_paginate {
        float: none;
        text-align: center;
        margin-top: 10px;
    }
    
    .paginate_button {
        padding: 0.3rem !important;
    }
}

/* Pantallas muy pequeñas */
@media (max-width: 479px) {
    .content-wrapper {
        padding: 10px;
        margin: 10px auto;
    }
    
    h1 {
        font-size: 1.3rem;
    }
    
    /* Configuración para pestaña Sin Acceder */
    #noaccess .row {
        flex-direction: column;
    }
    
    #noaccess .col-md-8, #noaccess .col-md-4 {
        width: 100%;
        padding: 0;
    }
    
    #noaccess .chart-container {
        height: 250px;
        margin: 10px 0;
    }
    
    /* Mejorar legibilidad de DataTables */
    .dataTables_wrapper .dataTables_filter input {
        width: 120px;
    }
    
    /* Permitir que las tablas se puedan desplazar horizontalmente */
    .table-container {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Mejoras para orientación landscape en móviles */
@media (max-height: 500px) and (orientation: landscape) {
    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
    }
    
    .chart-container {
        height: 200px;
    }
    
    .stats-container {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .stat-card {
        width: calc(50% - 20px);
        max-width: none;
    }
}

/* Mejoras específicas para tablas en dispositivos móviles */
@media (max-width: 767px) {
    table.dataTable thead .sorting:after,
    table.dataTable thead .sorting_asc:after,
    table.dataTable thead .sorting_desc:after {
        font-size: 0.7rem;
    }
    
    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 0.2em 0.5em;
    }
    
    .dataTables_wrapper .dataTables_length select {
        padding: 2px;
        width: 50px;
    }
}

/* Mejoras para la visualización de gráficos */
.chart-container {
    position: relative;
    margin: 0 auto;
}

/* Ajustes para las ventanas emergentes de los gráficos en móviles */
@media (max-width: 767px) {
    .chartjs-tooltip {
        font-size: 10px !important;
        padding: 3px 5px !important;
    }
}

/* Estilos para el loader */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loader-content {
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(0, 159, 227, 0.2);
    border-top: 5px solid #009fe3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Icono para botón exportar */
.export-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M11 16h2V7h3l-4-5-4 5h3v9zM5 18h14v2H5v-2z"/></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    margin-right: 5px;
    vertical-align: text-bottom;
}

/* Mejoras de accesibilidad */
.btn-export:focus,
.nav-link:focus {
    outline: 2px solid #009fe3;
    outline-offset: 2px;
}

/* Mejoras específicas para scroll en pantallas táctiles */
.touch-scroll {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.touch-scroll::-webkit-scrollbar {
    height: 6px;
    background-color: #f5f5f5;
}

.touch-scroll::-webkit-scrollbar-thumb {
    background-color: #009fe3;
    border-radius: 3px;
}

/* Optimizaciones para pantallas de alta densidad */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Animación para transiciones de pestañas */
.tab-pane.fade {
    transform: translateY(10px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.tab-pane.fade.show {
    transform: translateY(0);
    opacity: 1;
}

/* Animación para tarjetas de estadísticas */
.stat-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 159, 227, 0.2);
}

/* Mejoras para dispositivos con pantalla pequeña pero alta resolución */
@media (max-width: 767px) and (-webkit-min-device-pixel-ratio: 2), 
       (max-width: 767px) and (min-resolution: 192dpi) {
    .btn-export {
        padding: 8px 12px;
    }
    
    .nav-tabs .nav-link {
        padding: 10px 8px;
    }
}

/* Estilos para orientación de pantalla específica */
@media (orientation: portrait) and (max-width: 767px) {
    .stats-container {
        flex-direction: column;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    h1 {
        font-size: 1.3rem;
        margin-bottom: 0.3rem;
    }
    
    p.text-center {
        margin-bottom: 0.3rem;
    }
    
    .content-wrapper {
        padding: 10px;
        margin: 10px auto;
    }
    
    .tab-content {
        padding: 10px 5px;
    }
}

/* Estilos para pantallas extra pequeñas */
@media (max-width: 320px) {
    body {
        font-size: 13px;
    }
    
    h1 {
        font-size: 1.2rem;
    }
    
    h2 {
        font-size: 1.1rem;
    }
    
    .nav-tabs .nav-link {
        padding: 6px 4px;
        font-size: 0.75rem;
    }
    
    .btn-export {
        padding: 5px 8px;
        font-size: 0.75rem;
    }
    
    .dataTables_wrapper .dataTables_filter input {
        width: 100px;
    }
}

/* Optimizaciones para modo de ahorro de datos */
@media (prefers-reduced-data: reduce) {
    body {
        background-image: none;
        background-color: #f5f8fa;
    }
}

/* Optimizaciones para modo oscuro */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #f0f0f0;
    }
    
    .content-wrapper {
        background-color: rgba(40, 40, 40, 0.85);
    }
    
    h1, h2, h3 {
        color: #f0f0f0;
    }
    
    .nav-tabs .nav-link {
        color: #c0c0c0;
    }
    
    .nav-tabs .nav-link.active {
        color: #009fe3;
        background-color: rgba(0, 159, 227, 0.1);
    }
    
    .table {
        color: #f0f0f0;
    }
    
    .table>:not(caption)>*>* {
        background-color: rgba(255, 255, 255, 0.05) !important;
    }
    
    table.dataTable.table-striped>tbody>tr:nth-of-type(2n+1)>* {
        box-shadow: inset 0 0 0 9999px rgba(0, 159, 227, 0.1) !important;
    }
    
    .stat-card {
        background-color: rgba(50, 50, 50, 0.9);
        color: #f0f0f0;
    }
    
    .dashboard-footer {
        color: #a0a0a0;
    }
}

/* Estilo para mensajes de error */
.error-container {
    margin: 0 0 15px 0;
}

.alert-danger {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border-color: rgba(220, 53, 69, 0.2);
}
