/* ============================================================================
   VARIEDADES OSORTO - SISTEMA RESPONSIVE COMPLETO
   Archivo CSS Mobile-First para todo el sistema
   ============================================================================ */

/* ============================================================================
   1. VARIABLES CSS (Custom Properties)
   ============================================================================ */
:root {
    /* Colores principales */
    --color-primary: #007bff;
    --color-success: #28a745;
    --color-danger: #dc3545;
    --color-warning: #ffc107;
    --color-info: #17a2b8;
    --color-secondary: #6c757d;
    --color-dark: #343a40;
    --color-light: #f8f9fa;
    
    /* Espaciados */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Tamaños de fuente */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    
    /* Bordes */
    --border-radius: 0.375rem;
    --border-radius-lg: 0.5rem;
    
    /* Sombras */
    --shadow-sm: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
    --shadow-md: 0 0.5rem 1rem rgba(0,0,0,0.15);
    --shadow-lg: 0 1rem 3rem rgba(0,0,0,0.175);
    
    /* Transiciones */
    --transition-base: all 0.3s ease;
    --transition-fast: all 0.15s ease;
}

/* ============================================================================
   2. RESETEO Y BASE
   ============================================================================ */

/* Hacer que el box-sizing sea border-box para todos los elementos */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Body responsive base */
body {
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container responsive */
.container-fluid {
    padding-left: 10px;
    padding-right: 10px;
}

@media (min-width: 768px) {
    body {
        font-size: 16px;
    }
    
    .container-fluid {
        padding-left: 15px;
        padding-right: 15px;
    }
}

/* ============================================================================
   3. TIPOGRAFÍA RESPONSIVE
   ============================================================================ */

h1 { font-size: 1.5rem; margin-bottom: 0.75rem; }
h2 { font-size: 1.25rem; margin-bottom: 0.5rem; }
h3 { font-size: 1.125rem; margin-bottom: 0.5rem; }
h4 { font-size: 1rem; margin-bottom: 0.5rem; }
h5 { font-size: 0.95rem; margin-bottom: 0.5rem; }
h6 { font-size: 0.875rem; margin-bottom: 0.5rem; }

@media (min-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    h4 { font-size: 1.25rem; }
    h5 { font-size: 1.125rem; }
    h6 { font-size: 1rem; }
}

/* Texto pequeño más legible en móvil */
small, .small {
    font-size: 0.875rem;
}

/* ============================================================================
   4. TARJETAS ESTADÍSTICAS (STAT-CARDS)
   ============================================================================ */

.stat-card {
    border-left: 4px solid;
    transition: var(--transition-base);
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-card.ingreso { border-color: var(--color-success); }
.stat-card.egreso { border-color: var(--color-danger); }
.stat-card.saldo { border-color: var(--color-primary); }

.stat-card .card-body {
    padding: 12px;
}

.stat-card h2 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.stat-card h6 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.stat-card small {
    font-size: 0.7rem;
    display: block;
    margin-top: 0.25rem;
}

@media (min-width: 768px) {
    .stat-card .card-body {
        padding: 1rem;
    }
    
    .stat-card h2 {
        font-size: 1.75rem;
    }
    
    .stat-card h6 {
        font-size: 0.8rem;
    }
    
    .stat-card small {
        font-size: 0.8rem;
    }
}

/* Grid de tarjetas responsive */
.row.stat-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 576px) {
    .row.stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .row.stat-cards {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ============================================================================
   5. BOTONES RESPONSIVE
   ============================================================================ */

/* Todos los botones tienen altura táctil mínima */
.btn {
    min-height: 44px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: var(--border-radius);
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Botones de acción del cajero */
.btn-action {
    width: 100%;
    padding: 12px;
    font-size: 0.95rem;
    margin-bottom: 10px;
    border-radius: var(--border-radius);
    min-height: 48px;
}

@media (min-width: 768px) {
    .btn {
        font-size: 1rem;
    }
    
    .btn-action {
        padding: 15px;
        font-size: 1rem;
    }
}

/* Botones en grupos horizontales */
.btn-group-mobile {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

@media (min-width: 768px) {
    .btn-group-mobile {
        flex-direction: row;
        gap: 0.75rem;
    }
    
    .btn-group-mobile .btn {
        flex: 1;
    }
}

/* Botones de acción flotantes en móvil */
@media (max-width: 767px) {
    .btn-float-mobile {
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 1000;
        box-shadow: var(--shadow-lg);
        border-radius: 50%;
        width: 56px;
        height: 56px;
        padding: 0;
    }
}

/* ============================================================================
   6. TABLAS RESPONSIVE
   ============================================================================ */

/* Wrapper para tablas con scroll horizontal */
.table-responsive {
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Tablas base */
.table {
    font-size: 0.875rem;
    margin-bottom: 0;
}

.table th,
.table td {
    padding: 0.75rem 0.5rem;
    vertical-align: middle;
}

/* En móviles: tablas más compactas */
@media (max-width: 767px) {
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
    }
    
    .table {
        font-size: 0.75rem;
        min-width: 600px;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.35rem;
        white-space: nowrap;
    }
    
    /* Primera columna fija (sticky) */
    .table thead th:first-child,
    .table tbody td:first-child {
        position: sticky;
        left: 0;
        background-color: white;
        z-index: 10;
        box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    }
    
    .table thead th:first-child {
        background-color: #343a40;
        color: white;
        z-index: 11;
    }
    
    /* Ocultar columnas menos importantes en móvil */
    .table .hide-mobile {
        display: none;
    }
}

@media (min-width: 768px) {
    .table {
        font-size: 0.9rem;
    }
    
    .table th,
    .table td {
        padding: 0.75rem;
    }
}

/* DataTables responsive */
.dataTables_wrapper {
    font-size: 0.875rem;
}

@media (max-width: 767px) {
    /* Controles de DataTables apilados en móvil */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none !important;
        text-align: left !important;
        margin-bottom: 0.5rem;
    }
    
    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
    }
    
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: center !important;
        margin-top: 0.5rem;
    }
    
    /* Paginación más compacta */
    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.75rem !important;
    }
}

/* ============================================================================
   7. FORMULARIOS RESPONSIVE
   ============================================================================ */

/* Labels más claros en móvil */
.form-label {
    font-weight: 500;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

/* Inputs táctiles */
.form-control,
.form-select {
    min-height: 44px;
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
}

.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    border-color: var(--color-primary);
}

/* Inputs tipo number con botones grandes */
input[type="number"] {
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    height: 44px;
}

/* Textarea responsive */
textarea.form-control {
    min-height: 100px;
}

@media (min-width: 768px) {
    textarea.form-control {
        min-height: 120px;
    }
}

/* Select2 responsive (para búsquedas de clientes/productos) */
.select2-container {
    width: 100% !important;
}

.select2-container .select2-selection--single {
    min-height: 44px !important;
    padding: 0.375rem 0.75rem;
}

.select2-container .select2-selection__rendered {
    line-height: 44px !important;
}

.select2-container .select2-selection__arrow {
    height: 42px !important;
}

/* Grupos de formulario en grid responsive */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-grid.col-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Checkboxes y radios más grandes */
.form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.125rem;
}

.form-check-label {
    margin-left: 0.5rem;
    font-size: 0.95rem;
}

/* ============================================================================
   8. CARDS RESPONSIVE
   ============================================================================ */

.card {
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 0.75rem 1rem;
    font-weight: 600;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.card-body {
    padding: 1rem;
}

@media (max-width: 767px) {
    .card-header {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
}

/* Grid de cards */
.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1200px) {
    .card-grid.col-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================================================
   9. MODALES RESPONSIVE
   ============================================================================ */

@media (max-width: 767px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-content {
        border-radius: var(--border-radius);
    }
    
    .modal-header {
        padding: 0.75rem 1rem;
    }
    
    .modal-body {
        padding: 1rem;
        max-height: calc(100vh - 200px);
        overflow-y: auto;
    }
    
    .modal-footer {
        padding: 0.75rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }
    
    /* Modal fullscreen en móvil para formularios complejos */
    .modal-fullscreen-mobile {
        max-width: 100%;
        margin: 0;
        height: 100vh;
    }
    
    .modal-fullscreen-mobile .modal-content {
        height: 100%;
        border-radius: 0;
    }
}

/* SweetAlert2 responsive */
@media (max-width: 767px) {
    .swal2-popup {
        width: calc(100% - 2rem) !important;
        padding: 1rem !important;
    }
    
    .swal2-title {
        font-size: 1.25rem !important;
    }
    
    .swal2-html-container {
        font-size: 0.9rem !important;
    }
    
    .swal2-actions {
        flex-direction: column !important;
        width: 100%;
    }
    
    .swal2-actions button {
        width: 100% !important;
        margin: 0.25rem 0 !important;
    }
}

/* ============================================================================
   10. ALERTAS RESPONSIVE
   ============================================================================ */

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
}

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

/* ============================================================================
   11. BADGES Y ETIQUETAS
   ============================================================================ */

.badge {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    border-radius: var(--border-radius);
    font-weight: 500;
}

@media (max-width: 767px) {
    .badge {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
    }
}

/* ============================================================================
   12. NAVEGACIÓN / MENÚ
   ============================================================================ */

/* Sidebar responsive */
.sidebar {
    transition: var(--transition-base);
}

@media (max-width: 991px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        background-color: white;
        z-index: 1050;
        box-shadow: var(--shadow-lg);
        overflow-y: auto;
    }
    
    .sidebar.show {
        left: 0;
    }
    
    /* Overlay para cerrar sidebar */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        display: none;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    /* Botón hamburguesa */
    .btn-menu-toggle {
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 1030;
        width: 44px;
        height: 44px;
        padding: 0;
        background-color: var(--color-primary);
        color: white;
        border: none;
        border-radius: var(--border-radius);
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: var(--shadow-md);
    }
}

@media (min-width: 992px) {
    .btn-menu-toggle {
        display: none;
    }
}

/* Navegación horizontal */
.navbar {
    padding: 0.5rem 1rem;
}

@media (max-width: 767px) {
    .navbar {
        padding: 0.25rem 0.5rem;
    }
    
    .navbar-brand {
        font-size: 1rem;
    }
    
    .navbar-nav {
        margin-top: 0.5rem;
    }
    
    .nav-link {
        padding: 0.5rem 1rem;
    }
}

/* ============================================================================
   13. BREADCRUMBS RESPONSIVE
   ============================================================================ */

.breadcrumb {
    font-size: 0.875rem;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
}

@media (max-width: 767px) {
    .breadcrumb {
        font-size: 0.75rem;
        padding: 0.35rem 0;
        flex-wrap: nowrap;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .breadcrumb-item {
        display: inline-block;
    }
}

/* ============================================================================
   14. PAGINACIÓN RESPONSIVE
   ============================================================================ */

.pagination {
    flex-wrap: wrap;
    gap: 0.25rem;
}

.page-link {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 767px) {
    .page-link {
        min-width: 36px;
        min-height: 36px;
        font-size: 0.875rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Ocultar números intermedios en móvil */
    .pagination .d-none-mobile {
        display: none;
    }
}

/* ============================================================================
   15. DASHBOARD ESPECÍFICO
   ============================================================================ */

/* Grid del dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Widgets del dashboard */
.dashboard-widget {
    background: white;
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

@media (max-width: 767px) {
    .dashboard-widget {
        padding: 0.75rem;
    }
}

/* ============================================================================
   16. MÓDULO CAJERO/PUNTO DE VENTA
   ============================================================================ */

/* Panel de búsqueda de productos */
.search-box {
    position: relative;
}

#resultadosProductos {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    display: none;
}

.producto-item {
    cursor: pointer;
    padding: 0.75rem;
    border-bottom: 1px solid #eee;
    transition: var(--transition-fast);
}

.producto-item:hover {
    background-color: #f0f0f0;
}

@media (max-width: 767px) {
    .producto-item {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
}

/* Tabla de detalle de venta */
#tablaVenta {
    font-size: 0.875rem;
}

@media (max-width: 767px) {
    #tablaVenta {
        font-size: 0.75rem;
    }
    
    #tablaVenta th,
    #tablaVenta td {
        padding: 0.35rem 0.25rem;
    }
}

/* Total de factura */
.total-factura {
    font-size: 1.75rem;
    font-weight: bold;
    color: var(--color-success);
}

@media (max-width: 767px) {
    .total-factura {
        font-size: 1.5rem;
    }
}

/* ============================================================================
   17. LOGIN RESPONSIVE
   ============================================================================ */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
}

@media (max-width: 767px) {
    .login-card {
        max-width: 100%;
    }
    
    .login-card .card-body {
        padding: 1.5rem;
    }
}

/* ============================================================================
   18. IMPRESIÓN
   ============================================================================ */

@media print {
    /* Ocultar elementos no necesarios en impresión */
    .no-print,
    .btn,
    .navbar,
    .sidebar,
    .breadcrumb {
        display: none !important;
    }
    
    /* Ajustar tamaños para impresión */
    body {
        font-size: 12pt;
    }
    
    .table {
        font-size: 10pt;
    }
    
    /* Evitar saltos de página en elementos */
    .card,
    .table,
    tr,
    td {
        page-break-inside: avoid;
    }
}

/* ============================================================================
   19. UTILIDADES RESPONSIVE
   ============================================================================ */

/* Ocultar/mostrar según tamaño de pantalla */
@media (max-width: 575px) {
    .hide-xs { display: none !important; }
}

@media (max-width: 767px) {
    .hide-sm { display: none !important; }
}

@media (max-width: 991px) {
    .hide-md { display: none !important; }
}

@media (max-width: 1199px) {
    .hide-lg { display: none !important; }
}

/* Mostrar solo en móvil */
.show-mobile {
    display: block;
}

@media (min-width: 768px) {
    .show-mobile {
        display: none !important;
    }
}

/* Texto centrado en móvil */
@media (max-width: 767px) {
    .text-center-mobile {
        text-align: center !important;
    }
}

/* Ancho completo en móvil */
@media (max-width: 767px) {
    .w-100-mobile {
        width: 100% !important;
    }
}

/* Padding responsive */
@media (max-width: 767px) {
    .p-mobile-1 { padding: 0.5rem !important; }
    .p-mobile-2 { padding: 0.75rem !important; }
    .px-mobile-1 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
    .py-mobile-1 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
}

/* Margin responsive */
@media (max-width: 767px) {
    .m-mobile-1 { margin: 0.5rem !important; }
    .m-mobile-2 { margin: 0.75rem !important; }
    .mx-mobile-1 { margin-left: 0.5rem !important; margin-right: 0.5rem !important; }
    .my-mobile-1 { margin-top: 0.5rem !important; margin-bottom: 0.5rem !important; }
}

/* ============================================================================
   20. OPTIMIZACIONES DE RENDIMIENTO
   ============================================================================ */

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Mejorar rendimiento de animaciones */
.stat-card,
.btn,
.card {
    will-change: transform;
}

/* Optimizar fuentes */
body {
    text-rendering: optimizeLegibility;
    -webkit-tap-highlight-color: transparent;
}

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

/* ============================================================================
   21. ACCESIBILIDAD
   ============================================================================ */

/* Focus visible para teclado */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Skip to content para lectores de pantalla */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-primary);
    color: white;
    padding: 0.5rem 1rem;
    z-index: 10000;
}

.skip-to-content:focus {
    top: 0;
}

/* ============================================================================
   22. LOADING STATES
   ============================================================================ */

/* Spinner de carga */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* ============================================================================
   23. MODO LANDSCAPE EN MÓVILES
   ============================================================================ */

@media (max-width: 767px) and (orientation: landscape) {
    /* Reducir altura de header en landscape */
    .navbar {
        padding: 0.25rem 0.5rem;
    }
    
    /* Ajustar modales en landscape */
    .modal-body {
        max-height: calc(100vh - 120px);
    }
}

/* ============================================================================
   FIN DEL ARCHIVO CSS RESPONSIVE
   ============================================================================ */