/* ========================================
   EMEDOS - FIX MODALES E IMÁGENES
   ======================================== */

/* ============================================
   MODALES BOOTSTRAP - ESTILOS CRÍTICOS
   ============================================ */

/* Modal oculto por defecto */
.modal {
    display: none;
    position: fixed !important;  /* Importante: fixed para salir del flujo normal */
    top: 0 !important;
    left: 0 !important;
    z-index: 1055 !important;
    width: 100% !important;
    height: 100% !important;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
}

/* Modal visible */
.modal.show {
    display: block !important;
}

/* Contenido del modal centrado */
.modal-dialog {
    position: relative;
    width: auto;
    margin: 0.5rem;
    pointer-events: none;
}

@media (min-width: 576px) {
    .modal-dialog {
        max-width: 500px;
        margin: 1.75rem auto;
    }
    
    .modal-dialog-scrollable {
        height: calc(100% - 3.5rem);
    }
    
    .modal-dialog-centered {
        min-height: calc(100% - 3.5rem);
        display: flex;
        align-items: center;
    }
}

@media (min-width: 992px) {
    .modal-lg,
    .modal-xl {
        max-width: 800px;
    }
}

@media (min-width: 1200px) {
    .modal-xl {
        max-width: 1140px;
    }
}

/* Contenedor del modal */
.modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid rgba(0,0,0,.2);
    border-radius: 0.5rem;
    outline: 0;
}

/* Header del modal */
.modal-header {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1rem;
    border-bottom: 1px solid #dee2e6;
    border-top-left-radius: calc(0.5rem - 1px);
    border-top-right-radius: calc(0.5rem - 1px);
}

.modal-header .btn-close {
    padding: 0.5rem 0.5rem;
    margin: -0.5rem -0.5rem -0.5rem auto;
}

/* Body del modal */
.modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 1rem;
}

/* Footer del modal */
.modal-footer {
    display: flex;
    flex-wrap: wrap;
    flex-shrink: 0;
    align-items: center;
    justify-content: flex-end;
    padding: 0.75rem;
    border-top: 1px solid #dee2e6;
    border-bottom-right-radius: calc(0.5rem - 1px);
    border-bottom-left-radius: calc(0.5rem - 1px);
}

.modal-footer > * {
    margin: 0.25rem;
}

/* Backdrop del modal */
.modal-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 1050 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: #000;
}

.modal-backdrop.fade {
    opacity: 0;
}

.modal-backdrop.show {
    opacity: 0.5;
}

/* Animación fade */
.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
    transform: translate(0, -50px);
}

.modal.show .modal-dialog {
    transform: none;
}

/* Scrollable modal */
.modal-dialog-scrollable .modal-content {
    max-height: 100%;
    overflow: hidden;
}

.modal-dialog-scrollable .modal-body {
    overflow-y: auto;
}

/* Body con modal abierto */
body.modal-open {
    overflow: hidden !important;
}

/* ============================================
   IMÁGENES - FIX TAMAÑO
   ============================================ */

/* Imágenes contenidas en su contenedor */
img {
    max-width: 100%;
    height: auto;
}

/* Thumbnails de pedidos - forzar tamaño */
td img[alt*="Pedido"] {
    width: 64px !important;
    height: 64px !important;
    object-fit: cover !important;
}

/* Contenedor de imagen thumbnail */
.thumbnail-container {
    width: 64px;
    height: 64px;
    overflow: hidden;
    position: relative;
}

.thumbnail-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================
   Z-INDEX HIERARCHY
   ============================================ */

/* Select2 en modales */
.select2-container {
    z-index: 10060 !important;
}

.select2-dropdown {
    z-index: 10061 !important;
}

/* Choices.js en modales */
.choices__list--dropdown {
    z-index: 10061 !important;
}

/* ============================================
   UTILIDADES
   ============================================ */

/* Loading spinner centrado */
.spinner-border {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    vertical-align: text-bottom;
    border: 0.25em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
}

@keyframes spinner-border {
    to { transform: rotate(360deg); }
}

/* Botón cerrar modal */
.btn-close {
    box-sizing: content-box;
    width: 1em;
    height: 1em;
    padding: 0.25em 0.25em;
    color: #000;
    background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
    border: 0;
    border-radius: 0.25rem;
    opacity: 0.5;
}

.btn-close:hover {
    color: #000;
    text-decoration: none;
    opacity: 0.75;
}

.btn-close:focus {
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    opacity: 1;
}

.btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
}
