/* ════════════════════════════════════════════════════════════════════════════════
   RESPONSIVIDAD BOOTSTRAP 5 + ADMINLTE 4
   ════════════════════════════════════════════════════════════════════════════════
   
   Bootstrap 5 Breakpoints:
   - xs: 0px (default)
   - sm: 576px (small devices)
   - md: 768px (tablets)
   - lg: 992px (desktops)
   - xl: 1200px (large desktops)
   - xxl: 1400px (extra large desktops)
*/

/* ════════════════════════════════════════════════════════════════════════════════
   EXTRA LARGE DEVICES (xxl: >= 1400px)
   ════════════════════════════════════════════════════════════════════════════════ */

@media (min-width: 1400px) {
    .container-xxl {
        max-width: 1320px;
    }
    
    .sidebar {
        width: 280px;
    }
    
    .content-wrapper {
        margin-left: 280px;
    }
    
    .col-xxl-2 {
        flex: 0 0 auto;
        width: 16.66666667%;
    }
    
    .col-xxl-3 {
        flex: 0 0 auto;
        width: 25%;
    }
}

/* ════════════════════════════════════════════════════════════════════════════════
   LARGE DESKTOPS (lg: >= 992px)
   ════════════════════════════════════════════════════════════════════════════════ */

@media (min-width: 992px) {
    .sidebar {
        width: 250px;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        overflow-y: auto;
    }
    
    .content-wrapper {
        margin-left: 250px;
    }
    
    .navbar-expand-lg .navbar-collapse {
        display: flex !important;
        flex-basis: auto;
    }
    
    /* Modal responsive */
    .modal-lg {
        max-width: 900px;
    }
    
    .modal-xl {
        max-width: 1200px;
    }
    
    /* DataTables responsive */
    .dataTables_wrapper {
        overflow-x: visible;
    }
}

/* ════════════════════════════════════════════════════════════════════════════════
   TABLETS (md: >= 768px)
   ════════════════════════════════════════════════════════════════════════════════ */

@media (min-width: 768px) {
    /* Ajustes para AdminLTE */
    .sidebar {
        width: 230px;
    }
    
    .content-wrapper {
        margin-left: 230px;
    }
    
    /* Grid adjustments */
    .row > [class*='col-'] {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    /* Modal tablet */
    .modal-dialog {
        margin: 1.75rem auto;
    }
    
    .modal-lg {
        max-width: 800px;
    }
    
    /* DataTables en tablet */
    .dataTable thead {
        font-size: 0.875rem;
    }
    
    /* Cards en grid de 2 columnas */
    .card-grid .card {
        margin-bottom: 1rem;
    }
    
    /* Navbar responsive */
    .navbar-expand-md .navbar-toggler {
        display: none;
    }
}

/* ════════════════════════════════════════════════════════════════════════════════
   SMALL DEVICES (sm: >= 576px)
   ════════════════════════════════════════════════════════════════════════════════ */

@media (min-width: 576px) {
    /* Sidebar oculto en móviles */
    .sidebar {
        width: 200px;
        margin-left: -200px;
        transition: margin-left 0.3s ease;
    }
    
    .sidebar.show {
        margin-left: 0;
    }
    
    /* Modal en dispositivo pequeño */
    .modal-dialog {
        margin: 1.5rem 0.5rem;
    }
    
    /* Cards responsive */
    .card {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 1.25rem;
    }
    
    /* Ajustes de tabla */
    .table {
        font-size: 0.875rem;
    }
    
    /* Navbar toggle visible */
    .navbar-expand-sm .navbar-toggler {
        display: block;
    }
}

/* ════════════════════════════════════════════════════════════════════════════════
   DISPOSITIVOS EXTRA PEQUEÑOS (xs: < 576px / MOBILE)
   ════════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 575.98px) {
    /* Ocultar sidebar en móviles — activar con toggle */
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 100%;
        height: 100vh;
        background-color: var(--lte-sidebar-bg);
        z-index: 1040;
        transition: left 0.3s ease;
        overflow-y: auto;
        padding-bottom: 60px;
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .content-wrapper {
        margin-left: 0;
    }
    
    /* Modal fullscreen en móviles */
    .modal.fade .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100vh;
        display: flex;
        align-items: flex-end;
    }
    
    .modal-content {
        border-radius: 1rem 1rem 0 0;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* Cards a ancho completo */
    .card {
        margin-bottom: 0.75rem;
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    /* DataTables horizontal scroll */
    .dataTable {
        font-size: 0.8125rem;
        width: 100% !important;
    }
    
    .dataTables_wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Tablas responsivas */
    .table {
        margin-bottom: 0;
        font-size: 0.8rem;
    }
    
    .table thead {
        display: none;
    }
    
    .table tbody tr {
        display: block;
        border: 1px solid var(--lte-card-border);
        margin-bottom: 0.5rem;
        border-radius: 0.25rem;
    }
    
    .table tbody td {
        display: block;
        text-align: right;
        padding-left: 50%;
        position: relative;
        border: none;
        padding-top: 0.625rem;
        padding-bottom: 0.625rem;
    }
    
    .table tbody td::before {
        content: attr(data-label);
        position: absolute;
        left: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        font-size: 0.65rem;
        color: var(--color-primary);
    }
    
    /* Botones responsive */
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
        padding: 0.5rem 1rem;
    }
    
    .btn-sm {
        width: auto;
    }
    
    /* Navbar mobile */
    .navbar-expand-sm .navbar-toggler {
        display: block;
        border: none;
        padding: 0.25rem 0.75rem;
    }
    
    .navbar-collapse {
        display: none;
    }
    
    .navbar-collapse.show {
        display: block;
    }
    
    /* Forms mobile */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-label {
        display: block;
        margin-bottom: 0.5rem;
        font-weight: 600;
        font-size: 0.875rem;
    }
    
    .form-control,
    .form-select {
        width: 100%;
        padding: 0.5rem;
        font-size: 16px; /* Prevenir zoom en iOS */
    }
    
    /* Breadcrumb mobile */
    .breadcrumb {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
    
    .breadcrumb-item + .breadcrumb-item::before {
        content: " / ";
        margin: 0 0.25rem;
    }
    
    /* Pagination mobile */
    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .page-link {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Alert mobile */
    .alert {
        margin-bottom: 1rem;
        padding: 0.75rem;
    }
    
    /* Badge mobile */
    .badge {
        display: inline-block;
        padding: 0.35rem 0.65rem;
        font-size: 0.65rem;
    }
}

/* ════════════════════════════════════════════════════════════════════════════════
   ORIENTACIÓN LANDSCAPE EN MÓVILES
   ════════════════════════════════════════════════════════════════════════════════ */

@media (max-height: 600px) and (orientation: landscape) {
    .sidebar {
        height: auto;
        max-height: 100vh;
        overflow-y: auto;
    }
    
    .modal-content {
        max-height: calc(100vh - 2rem);
    }
    
    .table {
        font-size: 0.75rem;
    }
}

/* ════════════════════════════════════════════════════════════════════════════════
   PRINT STYLES
   ════════════════════════════════════════════════════════════════════════════════ */

@media print {
    .navbar,
    .sidebar,
    .footer,
    .btn,
    .pagination,
    .modal {
        display: none;
    }
    
    .content-wrapper {
        margin-left: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .table {
        color: #000;
        background-color: #fff;
    }
    
    .table-striped > tbody > tr:nth-of-type(odd) {
        background-color: #f5f5f5;
    }
}
