﻿﻿/* ============================================
   RESPONSIVE GLOBAL - Digit Soft
   Sistema completamente adaptable a móviles
   ============================================ */

/* Nota: viewport se controla desde <meta name="viewport"> en el HTML */

/* Variables CSS para facilitar cambios */
:root {
    --container-max-width: 1200px;
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
}

/* ============================================
   BASE RESPONSIVE
   ============================================ */

/* Asegurar que todo sea responsive por defecto */
* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    overflow-x: hidden !important;
    max-width: 100vw;
    /* display:flex y flex-direction son definidos en base.html para el layout sticky footer */
}

/* Contenedores responsive — Bootstrap 5 ya los define correctamente.
   Solo se mantiene overflow-x para evitar scroll horizontal no deseado. */
.container,
.container-fluid {
    overflow-x: hidden;
}

/* ============================================
   IMÁGENES RESPONSIVE
   ============================================ */

img {
    max-width: 100%;
    height: auto;
    display: block;
}

.img-fluid {
    max-width: 100%;
    height: auto;
}

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

.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 991px) {
    .table-responsive {
        border: 1px solid #dee2e6;
        border-radius: 0.25rem;
    }
}

/* Tablas en móviles - Stack vertical */
@media (max-width: 768px) {
    table.table-mobile-stack thead {
        display: none;
    }

    table.table-mobile-stack tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #ddd;
        border-radius: 0.25rem;
        padding: 0.5rem;
    }

    table.table-mobile-stack tbody td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem;
        border: none;
        border-bottom: 1px solid #eee;
    }

    table.table-mobile-stack tbody td:before {
        content: attr(data-label);
        font-weight: bold;
        margin-right: 0.5rem;
    }
}

/* ============================================
   GRID RESPONSIVE
   Nota: Bootstrap 5 ya maneja el grid responsive nativamente.
   Solo se definen reglas adicionales que Bootstrap 5 no cubre.
   ============================================ */

/* Grid system responsive - columnas extra que Bootstrap 5 no incluye en su versión min.
   NOTA: Esta regla es muy agresiva — Bootstrap 5 ya maneja col-* en xs.
   Solo se aplica dentro del dashboard (con-sidebar), no en la landing. */
@media (max-width: 575px) {
    .with-sidebar [class*="col-"]:not([class*="col-auto"]),
    .dashboard-layout [class*="col-"]:not([class*="col-auto"]) {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ============================================
   CARDS RESPONSIVE
   ============================================ */

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-color: #fff;
    border: 1px solid rgba(0,0,0,.125);
    border-radius: 0.25rem;
    margin-bottom: 1rem;
}

.card-body {
    flex: 1 1 auto;
    padding: 1.25rem;
}

@media (max-width: 576px) {
    .card-body {
        padding: 0.75rem;
    }
}

/* ============================================
   BOTONES RESPONSIVE
   ============================================ */

.btn {
    display: inline-block;
    font-weight: 400;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    user-select: none;
    border: 1px solid transparent;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 0.25rem;
    transition: all 0.15s ease-in-out;
    cursor: pointer;
}

@media (max-width: 576px) {
    /* Solo aplica width:100% a botones de formularios genéricos,
       NO a botones especiales de la landing y módulos */
    .btn:not(.btn-hero):not(.btn-hero-light):not(.btn-hero-outline-light):not(.btn-module):not(.btn-catalog):not(.btn-view-product):not(.ds-btn):not(.nav-link):not(.rounded-pill) {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .btn-group {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        border-radius: 0.25rem !important;
        margin-bottom: 0.5rem;
    }
}

/* ============================================
   FORMULARIOS RESPONSIVE
   ============================================ */

.form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
}

@media (max-width: 576px) {
    .form-control {
        font-size: 16px; /* Evita zoom en iOS */
    }

    .form-row {
        flex-direction: column;
    }

    .form-row > [class*="col-"] {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* ============================================
   NAVEGACIÓN RESPONSIVE
   Nota: Bootstrap 5 maneja el navbar nativamente.
   Solo se mantienen las reglas del hamburger button si se usa un botón custom.
   ============================================ */

/* Hamburger menu custom (solo si no se usa Bootstrap 5 navbar-toggler) */
.navbar-toggler {
    padding: 0.25rem 0.75rem;
    font-size: 1.25rem;
    line-height: 1;
    background-color: transparent;
    border: 1px solid transparent;
    border-radius: 0.25rem;
    cursor: pointer;
}


/* ============================================
   SIDEBAR RESPONSIVE
   ============================================ */

@media (max-width: 991px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 1050;
        transition: left 0.3s ease;
    }

    .sidebar.show {
        left: 0;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }

    .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;
    }

    /* Solo afecta al main-content dentro de un layout con sidebar */
    .with-sidebar .main-content,
    .dashboard-layout .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

/* ============================================
   ESTADÍSTICAS / CARDS DE MÉTRICAS
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

/* ============================================
   MODAL RESPONSIVE
   Nota: Bootstrap 5 maneja los modales nativamente.
   Solo se agregan ajustes en pantallas muy pequeñas.
   ============================================ */


@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-content {
        border-radius: 0.25rem;
    }
}

/* ============================================
   TEXTO RESPONSIVE
   ============================================ */

h1, .h1 {
    font-size: 2.5rem;
}

h2, .h2 {
    font-size: 2rem;
}

h3, .h3 {
    font-size: 1.75rem;
}

h4, .h4 {
    font-size: 1.5rem;
}

h5, .h5 {
    font-size: 1.25rem;
}

h6, .h6 {
    font-size: 1rem;
}

@media (max-width: 768px) {
    h1, .h1 { font-size: 2rem; }
    h2, .h2 { font-size: 1.75rem; }
    h3, .h3 { font-size: 1.5rem; }
    h4, .h4 { font-size: 1.25rem; }
    h5, .h5 { font-size: 1.1rem; }
}

@media (max-width: 576px) {
    h1, .h1 { font-size: 1.75rem; }
    h2, .h2 { font-size: 1.5rem; }
    h3, .h3 { font-size: 1.25rem; }
    h4, .h4 { font-size: 1.1rem; }
    h5, .h5 { font-size: 1rem; }
}

/* ============================================
   UTILIDADES RESPONSIVE
   ============================================ */

/* Ocultar en dispositivos específicos */
@media (max-width: 575px) {
    .d-sm-none { display: none !important; }
}

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

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

/* Mostrar solo en dispositivos específicos */
@media (min-width: 576px) {
    .d-sm-block { display: block !important; }
}

@media (min-width: 768px) {
    .d-md-block { display: block !important; }
}

@media (min-width: 992px) {
    .d-lg-block { display: block !important; }
}

/* Padding responsive */
@media (max-width: 576px) {
    .p-sm-1 { padding: 0.25rem !important; }
    .p-sm-2 { padding: 0.5rem !important; }
    .p-sm-3 { padding: 1rem !important; }

    .px-sm-1 { padding-left: 0.25rem !important; padding-right: 0.25rem !important; }
    .px-sm-2 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }

    .py-sm-1 { padding-top: 0.25rem !important; padding-bottom: 0.25rem !important; }
    .py-sm-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
}

/* Margin responsive */
@media (max-width: 576px) {
    .m-sm-1 { margin: 0.25rem !important; }
    .m-sm-2 { margin: 0.5rem !important; }
    .m-sm-3 { margin: 1rem !important; }
}

/* ============================================
   FLEX UTILITIES RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .flex-md-column {
        flex-direction: column !important;
    }

    .justify-content-md-center {
        justify-content: center !important;
    }

    .align-items-md-center {
        align-items: center !important;
    }
}

/* ============================================
   SCROLL HORIZONTAL EN MÓVIL
   ============================================ */

.horizontal-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .horizontal-scroll {
        display: block;
        width: 100%;
    }
}

/* ============================================
   SPACING RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .section {
        padding: 2rem 0;
    }

    .mb-md-3 {
        margin-bottom: 1rem !important;
    }

    .mt-md-3 {
        margin-top: 1rem !important;
    }
}

/* ============================================
   OVERFLOW CONTROL
   ============================================ */

.overflow-hidden {
    overflow: hidden !important;
}

.overflow-auto {
    overflow: auto !important;
}

.overflow-x-hidden {
    overflow-x: hidden !important;
}

/* ============================================
   TOUCH TARGETS (Accesibilidad móvil)
   Solo aplica a botones de acción, no a todos los enlaces
   ============================================ */

@media (max-width: 768px) {
    button,
    input[type="button"],
    input[type="submit"] {
        min-height: 44px;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .no-print {
        display: none !important;
    }

    .sidebar {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }
}

