/**
 * ESTILOS RESPONSIVE PARA DISPOSITIVOS MÓVILES
 * Optimizado para pantallas pequeñas, tablets y dispositivos táctiles
 */

/* ============================================================
 * MEJORAS GENERALES PARA MÓVILES
 * ============================================================ */

/* Asegurar que el viewport funcione correctamente */
html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Mejorar áreas táctiles */
a, button, .btn, input[type="submit"], input[type="button"] {
  min-height: 44px; /* Tamaño mínimo recomendado por Apple/Google */
  min-width: 44px;
}

/* ============================================================
 * RESPONSIVE BREAKPOINTS
 * ============================================================ */

/* Tablets y pantallas medianas (768px - 991px) */
@media (max-width: 991px) {
  .content-wrapper {
    margin-left: 0 !important;
  }
  
  .main-sidebar {
    transform: translateX(-230px);
    transition: transform 0.3s;
  }
  
  .sidebar-open .main-sidebar {
    transform: translateX(0);
  }
  
  /* Ajustar tablas */
  .table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Reducir padding en boxes */
  .box {
    margin-bottom: 15px;
  }
  
  .box-body {
    padding: 15px;
  }
}

/* Móviles en orientación horizontal y tablets pequeñas (576px - 767px) */
@media (max-width: 767px) {
  
  /* Header responsive */
  .main-header .logo {
    width: auto;
    padding: 0 15px;
  }
  
  .main-header .logo-lg {
    display: none;
  }
  
  .main-header .logo-mini {
    display: block !important;
  }
  
  /* Navbar */
  .main-header .navbar {
    margin-left: 0;
  }
  
  /* Content */
  .content-header > h1 {
    font-size: 20px;
  }
  
  .breadcrumb {
    font-size: 12px;
  }
  
  /* Small boxes (KPIs del dashboard) */
  .small-box {
    margin-bottom: 15px;
  }
  
  .small-box .inner h3 {
    font-size: 28px;
  }
  
  .small-box .inner p {
    font-size: 14px;
  }
  
  /* Botones en grupos */
  .btn-group {
    display: flex;
    flex-direction: column;
  }
  
  .btn-group > .btn {
    width: 100%;
    margin-bottom: 5px;
  }
  
  /* Modales */
  .modal-dialog {
    margin: 10px;
    width: auto;
  }
  
  /* Forms */
  .form-group {
    margin-bottom: 15px;
  }
  
  .form-control {
    font-size: 16px; /* Evita zoom automático en iOS */
  }
  
  /* Select2 */
  .select2-container--default .select2-selection--single {
    height: 40px;
    padding: 8px;
  }
  
  .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 24px;
  }
  
  /* DataTables */
  .dataTables_wrapper .dataTables_filter input {
    width: 100%;
    margin-bottom: 10px;
  }
  
  .dataTables_wrapper .dataTables_length select {
    width: auto;
  }
  
  .dataTables_info,
  .dataTables_paginate {
    float: none !important;
    text-align: center;
    margin-top: 10px;
  }
}

/* Móviles pequeños en orientación vertical (hasta 575px) */
@media (max-width: 575px) {
  
  /* Reducir padding general */
  .content-wrapper,
  .main-footer {
    padding: 10px;
  }
  
  .box {
    border-radius: 8px;
  }
  
  .box-header {
    padding: 10px;
  }
  
  .box-body {
    padding: 10px;
  }
  
  .box-footer {
    padding: 10px;
  }
  
  /* Títulos más pequeños */
  .content-header > h1 {
    font-size: 18px;
    margin: 0;
  }
  
  .box-title {
    font-size: 16px;
  }
  
  /* Botones responsivos */
  .btn {
    padding: 8px 15px;
    font-size: 14px;
  }
  
  .btn-block {
    width: 100%;
    margin-bottom: 10px;
  }
  
  /* Tablas responsive mejoradas */
  table.dataTable {
    font-size: 12px;
  }
  
  table.dataTable thead th,
  table.dataTable tbody td {
    padding: 8px 5px;
  }
  
  /* Ocultar columnas no críticas en móviles */
  table.dataTable .hide-mobile {
    display: none;
  }
  
  /* Inputs más grandes para táctil */
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="password"],
  textarea,
  select {
    font-size: 16px; /* Previene zoom en iOS */
    padding: 10px;
  }
  
  /* Modales fullscreen en móviles */
  .modal {
    padding: 0 !important;
  }
  
  .modal-dialog {
    margin: 0;
    max-width: 100%;
    height: 100%;
  }
  
  .modal-content {
    height: 100%;
    border-radius: 0;
  }
  
  .modal-body {
    overflow-y: auto;
    max-height: calc(100vh - 120px);
  }
  
  /* SweetAlert responsive */
  .swal2-popup {
    width: 90% !important;
    padding: 20px !important;
  }
  
  .swal2-title {
    font-size: 18px !important;
  }
  
  .swal2-content {
    font-size: 14px !important;
  }
  
  /* Iconos más grandes para táctil */
  .fa,
  .ion,
  .glyphicon {
    font-size: 18px;
  }
  
  /* Menú lateral en móviles */
  .sidebar-menu > li > a {
    padding: 12px 15px;
  }
  
  .sidebar-menu .treeview-menu > li > a {
    padding: 8px 15px 8px 35px;
  }
}

/* ============================================================
 * MEJORAS ESPECÍFICAS PARA RECETAS E INSUMOS
 * ============================================================ */

@media (max-width: 767px) {
  
  /* Tabla de insumos en recetas */
  #tablaInsumos {
    font-size: 14px;
  }
  
  #tablaInsumos td,
  #tablaInsumos th {
    padding: 8px 5px;
  }
  
  #tablaInsumos input[type="number"] {
    width: 100%;
    font-size: 16px;
  }
  
  #tablaInsumos select {
    width: 100%;
    font-size: 14px;
  }
  
  #tablaInsumos .btn {
    padding: 6px 10px;
    font-size: 12px;
  }
  
  /* Formulario de unidades de medida */
  .form-horizontal .control-label {
    text-align: left;
    padding-bottom: 5px;
  }
  
  .form-horizontal .form-group {
    margin-left: 0;
    margin-right: 0;
  }
}

/* ============================================================
 * MEJORAS PARA ACCESIBILIDAD TÁCTIL
 * ============================================================ */

/* Aumentar área de toque en elementos interactivos */
.btn-group-xs > .btn {
  min-height: 40px;
}

.pagination > li > a {
  min-width: 44px;
  min-height: 44px;
  line-height: 28px;
}

/* Mejorar contraste para lectura en exteriores */
@media (max-width: 575px) {
  body {
    font-size: 14px;
  }
  
  .text-muted {
    color: #666 !important;
  }
}

/* ============================================================
 * ORIENTACIÓN DE PANTALLA
 * ============================================================ */

/* Landscape (horizontal) en móviles */
@media (max-height: 500px) and (orientation: landscape) {
  .content-wrapper {
    padding: 5px;
  }
  
  .box {
    margin-bottom: 10px;
  }
  
  .modal-dialog {
    margin: 5px auto;
  }
}

/* ============================================================
 * DARK MODE (opcional para futuras mejoras)
 * ============================================================ */

@media (prefers-color-scheme: dark) {
  /* Descomenta para activar dark mode automático
  body {
    background-color: #1a1a1a;
    color: #e0e0e0;
  }
  
  .box {
    background-color: #2d2d2d;
    color: #e0e0e0;
  }
  
  .form-control {
    background-color: #3d3d3d;
    color: #e0e0e0;
    border-color: #555;
  }
  */
}

/* ============================================================
 * IMPRESIÓN (ocultar elementos innecesarios al imprimir)
 * ============================================================ */

@media print {
  .main-sidebar,
  .main-header,
  .content-header .breadcrumb,
  .btn,
  .box-footer,
  .pagination,
  .dataTables_filter,
  .dataTables_length,
  .dataTables_paginate {
    display: none !important;
  }
  
  .content-wrapper {
    margin: 0 !important;
    padding: 0 !important;
  }
  
  .box {
    border: 1px solid #ddd;
    box-shadow: none;
  }
}

/* ============================================================
 * ANIMACIONES SUAVES PARA TRANSICIONES
 * ============================================================ */

.main-sidebar,
.content-wrapper,
.modal,
.box {
  transition: all 0.3s ease;
}

/* Reducir animaciones si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

