/* ========================================
   ECODOCWEB - RESPONSIVE CUSTOM STYLES
   Mobile First Design with Bootstrap
   ======================================== */

/* ===========================================
   MOBILE FIRST BASE STYLES (XS: < 768px)
   =========================================== */

/* Body adjustments */
body {
    font-size: 14px;
    line-height: 1.6;
}

/* Container padding para móvil */
.page-content {
    padding: 15px !important;
}

/* Headers responsive */
h1, .h1 { font-size: 24px !important; }
h2, .h2 { font-size: 20px !important; }
h3, .h3 { font-size: 18px !important; }
h4, .h4 { font-size: 16px !important; }
h5, .h5 { font-size: 14px !important; }

.page-title {
    font-size: 24px !important;
    margin-bottom: 15px;
}

.page-title small {
    display: block;
    margin-top: 5px;
    font-size: 14px;
}

/* Botones táctiles más grandes */
.btn {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 14px;
    margin-bottom: 5px;
}

.btn-xs {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 13px;
}

.btn-sm {
    min-height: 40px;
    padding: 8px 14px;
}

.btn-lg {
    min-height: 50px;
    padding: 12px 20px;
}

/* Inputs más grandes para móvil */
.form-control {
    height: 44px;
    font-size: 16px; /* Evita zoom en iOS */
    padding: 10px 12px;
}

select.form-control {
    font-size: 16px;
    height: 44px;
}

textarea.form-control {
    font-size: 16px;
    min-height: 100px;
}

/* Portlets responsive */
.portlet {
    margin-bottom: 15px;
}

.portlet-title {
    padding: 12px 15px;
}

.portlet-title .caption {
    font-size: 16px;
}

.portlet-body {
    padding: 15px;
}

/* Tablas responsive wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #ddd;
    margin-bottom: 15px;
    border-radius: 4px;
}

.table-responsive > .table {
    margin-bottom: 0;
}

/* Tablas: columnas mínimas */
.table > thead > tr > th,
.table > tbody > tr > td {
    white-space: nowrap;
    min-width: 100px;
    font-size: 13px;
    padding: 8px;
}

.table > thead > tr > th:first-child,
.table > tbody > tr > td:first-child {
    min-width: 50px; /* Columna de checkbox/ID */
}

.table > thead > tr > th:last-child,
.table > tbody > tr > td:last-child {
    min-width: 120px; /* Columna de acciones */
}

/* DataTables responsive */
.dataTables_wrapper {
    padding: 0;
    width: 100%;
}

.dataTables_filter {
    margin-bottom: 10px;
}

.dataTables_filter input {
    width: 100% !important;
    margin-left: 0 !important;
    margin-bottom: 10px;
}

.dataTables_length {
    margin-bottom: 10px;
}

.dataTables_length select {
    width: auto;
    display: inline-block;
}

.dataTables_info {
    padding-top: 10px;
    font-size: 13px;
}

.dataTables_paginate {
    padding-top: 10px;
}

/* DataTables Responsive extension styles */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.child,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.child,
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dataTables_empty {
    cursor: default !important;
}

table.dataTable.dtr-inline.collapsed > tbody > tr > td.child:before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.child:before,
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dataTables_empty:before {
    display: none !important;
}

/* Botón expandir/contraer alineado correctamente */
table.dataTable.dtr-inline.collapsed > tbody > tr[role="row"] > td:first-child:before,
table.dataTable.dtr-inline.collapsed > tbody > tr[role="row"] > th:first-child:before {
    top: 50%;
    left: 8px;
    height: 18px;
    width: 18px;
    margin-top: -9px;
    display: block;
    position: absolute;
    color: white;
    border: 2px solid white;
    border-radius: 18px;
    box-shadow: 0 0 3px #444;
    box-sizing: content-box;
    text-align: center;
    text-indent: 0 !important;
    font-family: 'Courier New', Courier, monospace;
    line-height: 18px;
    content: '+';
    background-color: #31b131;
    font-weight: bold;
    font-size: 14px;
}

table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td:first-child:before,
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > th:first-child:before {
    content: '−';
    background-color: #d33333;
}

/* Alineación correcta de primera celda */
table.dataTable.dtr-inline.collapsed > tbody > tr > td:first-child,
table.dataTable.dtr-inline.collapsed > tbody > tr > th:first-child {
    position: relative;
    padding-left: 50px !important;
    cursor: pointer;
    vertical-align: middle;
    text-align: left;
}

/* Alineación del checkbox si existe en primera columna */
table.dataTable.dtr-inline.collapsed > tbody > tr > td:first-child input[type="checkbox"],
table.dataTable.dtr-inline.collapsed > tbody > tr > th:first-child input[type="checkbox"] {
    margin-left: 8px;
    vertical-align: middle;
    margin-top: -2px;
}

table.dataTable.dtr-inline.collapsed > tbody > tr.child td {
    padding: 0.5em 1em 0.5em 1em !important;
}

table.dataTable.dtr-inline.collapsed.compact > tbody > tr > td:first-child,
table.dataTable.dtr-inline.collapsed.compact > tbody > tr > th:first-child {
    padding-left: 40px;
}

table.dataTable.dtr-inline.collapsed.compact > tbody > tr[role="row"] > td:first-child:before,
table.dataTable.dtr-inline.collapsed.compact > tbody > tr[role="row"] > th:first-child:before {
    top: 50%;
    left: 8px;
    height: 16px;
    width: 16px;
    margin-top: -8px;
    border-radius: 16px;
    line-height: 16px;
    text-indent: 2px;
    font-size: 12px;
}

/* Responsive child rows */
table.dataTable > tbody > tr.child ul.dtr-details {
    display: block;
    list-style-type: none;
    margin: 0;
    padding: 0;
}

table.dataTable > tbody > tr.child ul.dtr-details > li {
    border-bottom: 1px solid #efefef;
    padding: 0.5em 0;
}

table.dataTable > tbody > tr.child ul.dtr-details > li:first-child {
    padding-top: 0;
}

table.dataTable > tbody > tr.child ul.dtr-details > li:last-child {
    border-bottom: none;
}

table.dataTable > tbody > tr.child span.dtr-title {
    display: inline-block;
    min-width: 75px;
    font-weight: bold;
}

/* Responsive inline details table */
table.dataTable tr.child table.table {
    margin: 10px 0;
    width: 100% !important;
}

table.dataTable tr.child table.table td.responsive-title {
    font-weight: 600;
    width: 30%;
    min-width: 100px;
    vertical-align: top;
    padding-right: 10px;
}

table.dataTable tr.child table.table td.responsive-data {
    width: 70%;
    word-break: break-word;
}

/* DataTables scroll en móvil */
.dataTables_wrapper .dataTables_scroll {
    width: 100%;
}

.dataTables_wrapper .dataTables_scrollBody {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* Paginación responsive */
.dataTables_wrapper .dataTables_paginate {
    text-align: center;
    margin-top: 15px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 5px 10px;
    margin: 0 2px;
    display: inline-block;
    min-width: 38px;
    text-align: center;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: #3f51b5;
    color: white !important;
    border-radius: 3px;
}

/* Filtros y controles responsive */
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_length {
    width: 100%;
    margin-bottom: 10px;
}

.dataTables_wrapper .dataTables_filter label,
.dataTables_wrapper .dataTables_length label {
    width: 100%;
    display: block;
}

.dataTables_wrapper .dataTables_filter input {
    width: 100% !important;
    max-width: 100% !important;
}

/* Table container responsive */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Breadcrumb responsive */
.page-breadcrumb {
    padding: 10px 0;
    margin-bottom: 15px;
}

.page-breadcrumb > li {
    font-size: 13px;
}

.page-breadcrumb > li + li:before {
    padding: 0 5px;
}

/* Formularios en grid */
.form-horizontal .form-group {
    margin-left: 0;
    margin-right: 0;
}

.form-horizontal .control-label {
    text-align: left;
    padding-top: 8px;
    margin-bottom: 5px;
    font-weight: 600;
}

/* Espaciado responsive */
.margin-top-10 { margin-top: 10px !important; }
.margin-bottom-10 { margin-bottom: 10px !important; }
.padding-10 { padding: 10px !important; }
.margin-top-20 { margin-top: 20px !important; }
.margin-bottom-20 { margin-bottom: 20px !important; }

/* ==========================================
   MOBILE SIDEBAR - ADMINLTE STANDARD
   ========================================== */
@media (max-width: 991px) {
    /* Sidebar animado de izquierda a derecha en móvil */
    .page-sidebar {
        position: fixed !important;
        left: -260px !important;
        top: 0;
        bottom: 0;
        z-index: 10002 !important;
        width: 260px !important;
        transition: left 0.3s ease;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Sidebar abierto */
    .page-sidebar.in {
        left: 0 !important;
    }

    /* Fondo oscuro cuando menú abierto */
    .sidebar-overlay {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998 !important;
        display: none;
    }

    .sidebar-overlay.active {
        display: block !important;
    }

    /* Content ocupa todo el ancho en móvil */
    .page-content-wrapper {
        margin-left: 0 !important;
    }

    /* Botón flotante para abrir menú */
    .mobile-menu-toggle {
        display: block !important;
    }

    /* Ocultar en desktop */
    .mobile-menu-toggle {
        opacity: 1;
        transition: opacity 0.3s;
    }

    body.mobile-menu-open .mobile-menu-toggle {
        opacity: 0;
        pointer-events: none;
    }
}

/* Ocultar botón en pantallas grandes */
@media (min-width: 992px) {
    .mobile-menu-toggle {
        display: none !important;
    }

    .sidebar-overlay {
        display: none !important;
    }
}

@media (min-width: 1200px) {
    .mobile-menu-toggle {
        display: none;
    }
    .sidebar-overlay {
        display: none !important;
    }
}

/* Header responsive */
.page-header.navbar {
    min-height: 50px;
}

@media (max-width: 767px) {
    .page-header.navbar {
        padding-left: 15px;
        padding-right: 15px;
    }

    .page-header .top-menu {
        margin-right: 0;
    }

    .page-header .navbar-brand {
        padding: 10px 15px;
    }
}

/* Mobile menu toggle */
.mobile-menu-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10005;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: #3f51b5;
    color: white;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    font-size: 24px;
    display: block;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mobile-menu-toggle:hover {
    background-color: #303f9f;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.mobile-menu-toggle:focus {
    outline: none;
}

/* Overlay oscuro cuando menú abierto */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    display: none;
    cursor: pointer;
}

.sidebar-overlay.active {
    display: block;
}

/* Modales responsive */
.modal-dialog {
    margin: 10px;
}

.modal-body {
    padding: 15px;
}

.modal-header {
    padding: 15px;
}

.modal-footer {
    padding: 15px;
}

/* Alertas responsive */
.alert {
    padding: 12px;
    font-size: 14px;
    margin-bottom: 15px;
}

/* Cards/Widgets responsive */
.dashboard-stat2 {
    padding: 15px;
    margin-bottom: 15px;
    min-height: auto !important;
}

.dashboard-stat2 .display {
    margin-bottom: 10px;
}

.dashboard-stat2 .display .number h3 {
    font-size: 24px !important;
}

.dashboard-stat2 .display .icon {
    font-size: 40px;
}

/* Imágenes responsive */
img {
    max-width: 100%;
    height: auto;
}

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

/* Logo responsive */
.page-logo img {
    max-width: 100%;
    height: auto;
}

/* Actions en portlet title */
.portlet-title .actions {
    margin-top: 5px;
}

.portlet-title .actions .btn {
    margin-left: 5px;
}

/* Form actions */
.form-actions {
    padding: 15px;
    margin-top: 20px;
    border-top: 1px solid #e5e5e5;
}

/* Notes/descriptions */
.note {
    padding: 10px;
    font-size: 13px;
}

/* Scroll indicator para tablas */
.scroll-indicator {
    text-align: center;
    padding: 8px;
    background: #f9f9f9;
    border-top: 1px solid #ddd;
    font-size: 12px;
    color: #666;
}

.scroll-indicator i {
    margin-right: 5px;
}

/* Select2 responsive */
.select2-container {
    width: 100% !important;
}

.select2-container .select2-selection--single {
    height: 44px !important;
}

.select2-container .select2-selection--single .select2-selection__rendered {
    line-height: 42px !important;
    padding-left: 12px !important;
}

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

/* Tooltips en móvil - desactivar */
.tooltip {
    pointer-events: none;
}

/* ===========================================
   SMALL DEVICES (SM: 768px - 991px) TABLETS
   =========================================== */

@media (min-width: 768px) {
    
    /* Body y contenedores */
    body {
        font-size: 14px;
    }
    
    .page-content {
        padding: 20px !important;
    }
    
    /* Headers */
    h1, .h1 { font-size: 28px !important; }
    h2, .h2 { font-size: 24px !important; }
    h3, .h3 { font-size: 20px !important; }
    
    .page-title {
        font-size: 28px !important;
    }
    
    /* Formularios */
    .form-horizontal .control-label {
        text-align: right;
        padding-top: 7px;
        margin-bottom: 0;
        font-weight: normal;
    }
    
    /* Tablas */
    .table > thead > tr > th,
    .table > tbody > tr > td {
        font-size: 14px;
        padding: 10px;
    }
    
    /* Portlets */
    .portlet-title {
        padding: 15px 20px;
    }
    
    .portlet-title .caption {
        font-size: 18px;
    }
    
    .portlet-body {
        padding: 20px;
    }
    
    /* Ocultar botón móvil en tablet/desktop */
    .mobile-menu-toggle {
        display: none;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
    
    /* Modales más grandes */
    .modal-dialog {
        width: 600px;
        margin: 30px auto;
    }
    
    /* Dashboard stats */
    .dashboard-stat2 .display .number h3 {
        font-size: 28px !important;
    }
    
    .dashboard-stat2 .display .icon {
        font-size: 50px;
    }
}

/* ===========================================
   MEDIUM DEVICES (MD: 992px - 1199px) DESKTOP
   =========================================== */

@media (min-width: 992px) {
    
    .page-content {
        padding: 25px 20px !important;
    }
    
    /* Headers */
    h1, .h1 { font-size: 32px !important; }
    h2, .h2 { font-size: 26px !important; }
    h3, .h3 { font-size: 22px !important; }
    
    .page-title {
        font-size: 32px !important;
    }
    
    /* Tablas con más espacio */
    .table > thead > tr > th,
    .table > tbody > tr > td {
        padding: 12px;
        font-size: 14px;
    }
    
    /* Modales más grandes */
    .modal-lg {
        width: 900px;
    }
    
    /* Dashboard stats */
    .dashboard-stat2 .display .number h3 {
        font-size: 32px !important;
    }
    
    .dashboard-stat2 .display .icon {
        font-size: 60px;
    }
}

/* ===========================================
   LARGE DEVICES (LG: >= 1200px) LARGE DESKTOP
   =========================================== */

@media (min-width: 1200px) {
    
    .page-content {
        padding: 30px 20px !important;
    }
    
    /* Headers */
    h1, .h1 { font-size: 36px !important; }
    h2, .h2 { font-size: 28px !important; }
    
    .page-title {
        font-size: 36px !important;
    }
    
    /* Container más ancho */
    .container {
        width: 1170px;
    }
    
    /* Modales XL */
    .modal-xl {
        width: 1140px;
    }
    
    /* Dashboard stats */
    .dashboard-stat2 .display .number h3 {
        font-size: 36px !important;
    }
}

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

/* Botones full width en móvil */
@media (max-width: 767px) {
    .btn-block-xs {
        display: block;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .no-padding-xs { 
        padding: 0 !important; 
    }
    
    .no-margin-xs { 
        margin: 0 !important; 
    }
    
    /* Acciones de formulario full width */
    .form-actions .btn {
        display: block;
        width: 100%;
        margin-bottom: 10px;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Actions en portlet */
    .portlet-title .actions {
        text-align: left;
        width: 100%;
        margin-top: 10px;
    }
    
    .portlet-title .actions .btn {
        display: block;
        width: 100%;
        margin-left: 0;
        margin-bottom: 5px;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .btn-block-sm {
        display: block;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .no-padding-sm { 
        padding: 0 !important; 
    }
    
    .no-margin-sm { 
        margin: 0 !important; 
    }
}

/* Grid helpers */
.row-flex {
    display: flex;
    flex-wrap: wrap;
}

.col-flex {
    display: flex;
    flex-direction: column;
}

/* Responsive debug helper */
.responsive-debugger {
    position: fixed;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    z-index: 10001;
    font-family: monospace;
}

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

@media print {
    
    .page-sidebar,
    .page-header,
    .page-footer,
    .breadcrumb,
    .btn,
    .mobile-menu-toggle,
    .sidebar-overlay,
    .responsive-debugger,
    .form-actions,
    .portlet-title .actions {
        display: none !important;
    }
    
    .page-content-wrapper {
        margin: 0 !important;
    }
    
    .page-content {
        padding: 0 !important;
    }
    
    .portlet {
        border: none !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }
    
    .table {
        border-collapse: collapse !important;
    }
    
    .table td,
    .table th {
        border: 1px solid #ddd !important;
    }
}

/* ===========================================
   ACCESSIBILITY IMPROVEMENTS
   =========================================== */

/* Focus visible para navegación con teclado */
*:focus {
    outline: 2px solid #3f51b5;
    outline-offset: 2px;
}

button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #3f51b5;
    outline-offset: 2px;
}

/* Skip to content link */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: #3f51b5;
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100000;
}

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

/* ===========================================
   PERFORMANCE OPTIMIZATIONS
   =========================================== */

/* Hardware acceleration */
.page-sidebar,
.mobile-menu-toggle,
.sidebar-overlay {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

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

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
