/* ================================================
   ESTILOS PARA SISTEMA DE APARTADOS - RESPONSIVE
   ================================================ */

/* ========================================
   SELECT2 - Mejoras generales
   ======================================== */
.select2-container {
  width: 100% !important;
}

.select2-container--default .select2-selection--single {
  height: 38px !important;
  border: 1px solid #d2d6de !important;
  border-radius: 4px !important;
  padding: 6px 12px !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 24px !important;
  color: #555 !important;
  padding-left: 0 !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 36px !important;
}

.select2-container--open .select2-dropdown {
  z-index: 9999 !important;
}

/* ========================================
   SELECT2 en modales
   ======================================== */
.modal .select2-container {
  z-index: 1055 !important;
}

.modal .select2-dropdown {
  z-index: 1056 !important;
}

.modal-body .select2-container {
  width: 100% !important;
}

/* ========================================
   SELECT2 - Estados de validación
   ======================================== */
.select2-container--default.select2-container--focus .select2-selection--single {
  border-color: #3c8dbc !important;
  outline: 0 !important;
  box-shadow: 0 0 0 0.2rem rgba(60, 141, 188, 0.25) !important;
}

.has-error .select2-container--default .select2-selection--single {
  border-color: #dd4b39 !important;
}

.has-success .select2-container--default .select2-selection--single {
  border-color: #00a65a !important;
}

/* ========================================
   SELECT2 - Resultados y búsqueda
   ======================================== */
.select2-results__option {
  padding: 8px 12px !important;
  font-size: 14px !important;
}

.select2-results__option--highlighted {
  background-color: #3c8dbc !important;
  color: white !important;
}

.select2-search--dropdown .select2-search__field {
  border: 1px solid #d2d6de !important;
  border-radius: 4px !important;
  padding: 8px 12px !important;
  font-size: 14px !important;
}

.select2-search--dropdown .select2-search__field:focus {
  border-color: #3c8dbc !important;
  outline: 0 !important;
}

/* ========================================
   SELECT2 - Mensajes de estado
   ======================================== */
.select2-results__message {
  color: #666 !important;
  font-size: 13px !important;
  padding: 12px !important;
}

/* ========================================
   RESPONSIVE - Pantallas pequeñas
   ======================================== */
@media (max-width: 768px) {
  /* Modal en pantalla completa en móviles */
  .modal-dialog {
    margin: 0 !important;
    width: 100% !important;
    max-width: none !important;
    height: 100% !important;
  }
  
  .modal-content {
    height: 100% !important;
    border-radius: 0 !important;
    overflow-y: auto !important;
  }
  
  .modal-body {
    padding: 15px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  /* Select2 en móviles */
  .select2-container--default .select2-selection--single {
    height: 44px !important;
    font-size: 16px !important; /* Evita zoom en iOS */
    padding: 10px 12px !important;
  }
  
  .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 24px !important;
    font-size: 16px !important;
  }
  
  .select2-search--dropdown .select2-search__field {
    font-size: 16px !important; /* Evita zoom en iOS */
    padding: 10px 12px !important;
    height: 44px !important;
  }
  
  .select2-results__option {
    padding: 12px 15px !important;
    font-size: 16px !important;
  }
  
  /* Dropdown del Select2 */
  .select2-dropdown {
    font-size: 16px !important;
  }
  
  /* Input groups en móviles */
  .input-group {
    flex-wrap: nowrap !important;
  }
  
  .input-group-addon {
    min-width: 40px !important;
    font-size: 14px !important;
  }
  
  .form-control {
    font-size: 16px !important; /* Evita zoom en iOS */
    height: 44px !important;
  }
  
  /* Tabla de productos en móviles */
  .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  /* Botones en móviles */
  .btn {
    padding: 10px 15px !important;
    font-size: 14px !important;
    touch-action: manipulation !important;
  }
}

/* ========================================
   RESPONSIVE - Tablets
   ======================================== */
@media (min-width: 769px) and (max-width: 1024px) {
  .modal-dialog {
    width: 90% !important;
    margin: 30px auto !important;
  }
  
  .select2-container--default .select2-selection--single {
    height: 40px !important;
  }
  
  .form-control {
    height: 40px !important;
  }
}

/* ========================================
   CAMPOS DESHABILITADOS
   ======================================== */
.form-control:disabled,
.form-control[readonly] {
  background-color: #eee !important;
  cursor: not-allowed !important;
  opacity: 1 !important;
}

.select2-container--disabled .select2-selection {
  background-color: #eee !important;
  cursor: not-allowed !important;
}

/* ========================================
   INPUT DE ESTADO DE PAGO
   ======================================== */
.input-success {
  background-color: #dff0d8 !important;
  color: #3c763d !important;
  font-weight: bold !important;
  border-color: #00a65a !important;
}

.input-error {
  background-color: #f2dede !important;
  color: #a94442 !important;
  font-weight: bold !important;
  border-color: #dd4b39 !important;
}

/* ========================================
   TOUCH - Mejoras para dispositivos táctiles
   ======================================== */
@media (hover: none) and (pointer: coarse) {
  /* Aumentar área táctil de botones */
  .btn {
    min-height: 44px !important;
    min-width: 44px !important;
  }
  
  /* Mejorar selects táctiles */
  select,
  input[type="text"],
  input[type="number"],
  textarea {
    min-height: 44px !important;
    font-size: 16px !important; /* Prevenir zoom en iOS */
  }
  
  /* Prevenir zoom en inputs en iOS */
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="tel"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ========================================
   ANIMACIONES SUAVES
   ======================================== */
.select2-container,
.form-control,
.btn {
  transition: all 0.2s ease-in-out !important;
}

/* ========================================
   CORRECCIÓN DE Z-INDEX
   ======================================== */
.modal-backdrop {
  z-index: 1040 !important;
}

.modal {
  z-index: 1050 !important;
}

.select2-container--open {
  z-index: 1060 !important;
}

.select2-dropdown {
  z-index: 1061 !important;
}

/* ========================================
   TABLAS RESPONSIVAS
   ======================================== */
@media (max-width: 768px) {
  table.table-bordered {
    font-size: 13px !important;
  }
  
  table.table-bordered th,
  table.table-bordered td {
    padding: 6px !important;
    white-space: nowrap !important;
  }
  
  /* Ajustar columnas de productos */
  #nuevosProductos select,
  #nuevosProductos input {
    min-width: 120px !important;
  }
}

/* ========================================
   ACCESIBILIDAD
   ======================================== */
.select2-container:focus,
.select2-selection:focus {
  outline: 2px solid #3c8dbc !important;
  outline-offset: 2px !important;
}

button:focus,
input:focus,
select:focus {
  outline: 2px solid #3c8dbc !important;
  outline-offset: 1px !important;
}

/* ========================================
   LOADING STATES
   ======================================== */
.select2-results__option.loading-results {
  color: #999 !important;
  font-style: italic !important;
}

.select2-container--default .select2-results__option[aria-disabled=true] {
  color: #999 !important;
  cursor: not-allowed !important;
}

