/* ==========================================================
   SPV V3 - Estabilización visual / responsive
   Carga al final para corregir desbordes sin reemplazar el tema.
   ========================================================== */

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.content-wrapper,
.main-header,
.main-footer,
.panel-medio-principal,
.panel-medio,
.box,
.box-body {
  min-width: 0;
  max-width: 100%;
}

.box-body,
.table-responsive,
.dataTables_wrapper {
  width: 100%;
}

.table-responsive,
.box-body {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.dataTables_wrapper .row {
  margin-left: 0;
  margin-right: 0;
}

.dataTables_wrapper table.dataTable,
table.dataTable {
  width: 100% !important;
  max-width: 100% !important;
}

.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
  max-width: 100%;
}

.select2-container,
.select2-container--default,
.form-control,
.input-group,
.input-custom-group {
  max-width: 100%;
}

.select2-container {
  width: 100% !important;
}

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

.modal-dialog {
  max-width: calc(100vw - 20px);
}

.modal-content,
.modal-body,
.modal-footer,
.modal-header {
  max-width: 100%;
}

.modal-body {
  overflow-x: auto;
}

.modal img,
.box img {
  max-width: 100%;
  height: auto;
}

/* Evita que botones largos rompan encabezados y pies de modal. */
.modal-footer .btn,
.box-header .btn,
.dashboard-header .btn {
  white-space: normal;
}

/* Los complementos de Bootstrap a veces dejan anchos inline excesivos. */
.bootstrap-select,
.bootstrap-select > .dropdown-toggle {
  max-width: 100% !important;
}

/* Acciones en tablas: mantenerlas juntas sin comprimir el resto de columnas. */
.tbl-t .btn-group,
.table .btn-group {
  display: inline-flex;
  flex-wrap: nowrap;
}

/* Corrección para inputs con botones laterales dentro de presentaciones/productos. */
.input-custom-group {
  display: flex;
  align-items: stretch;
  width: 100%;
}

.input-custom-group > .form-control {
  min-width: 0;
  flex: 1 1 auto;
}

.input-custom-group > .input-group-addon,
.input-custom-group > .btn {
  flex: 0 0 auto;
}

@media (max-width: 991px) {
  .panel-medio,
  .container-fluid.panel-medio,
  .container-fluid {
    max-width: 100%;
  }

  .dashboard-header .btns-dash {
    padding-left: 0;
    padding-right: 0;
  }
}

@media (max-width: 767px) {
  .content-wrapper,
  .main-footer {
    margin-left: 0 !important;
  }

  .panel-medio,
  .container-fluid.panel-medio,
  section.container-fluid {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .box {
    margin-left: 0;
    margin-right: 0;
  }

  .box-header,
  .box-body {
    padding-left: 10px;
    padding-right: 10px;
  }

  .modal-dialog,
  .modal-forms .modal-dialog,
  .fullscreen-modal .modal-dialog {
    width: auto !important;
    max-width: none !important;
    margin: 10px !important;
  }

  .modal-body {
    padding: 12px;
  }

  .modal-footer {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  .modal-footer .btn {
    float: none !important;
    margin: 0 !important;
    flex: 1 1 150px;
  }

  .dashboard-header .pull-right,
  .box-header > .pull-right {
    float: none !important;
    display: block;
    width: 100%;
    margin: 6px 0 !important;
  }

  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter {
    text-align: left !important;
    width: 100%;
    margin-bottom: 8px;
  }

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

  .dataTables_wrapper .dataTables_filter input {
    width: calc(100% - 65px) !important;
    max-width: 260px;
  }

  .dataTables_wrapper .dataTables_paginate {
    overflow-x: auto;
    white-space: nowrap;
    width: 100%;
  }

  /* En móvil las tablas administrativas deben desplazarse, no aplastarse. */
  .box-body > table.table,
  .table-responsive > table.table,
  .dataTables_wrapper > table.table {
    min-width: 620px;
  }

  .input-custom-group {
    flex-wrap: wrap;
  }

  .input-custom-group > .input-group-addon {
    min-width: 40px;
  }

  .input-custom-group > .btn {
    margin-top: 6px;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .modal-dialog,
  .modal-forms .modal-dialog {
    margin: 5px !important;
  }

  .modal-header h4,
  .modal-title {
    font-size: 16px;
    line-height: 1.3;
    padding-right: 24px;
  }

  .btn {
    max-width: 100%;
  }
}
