/* Popup Input Fix - Additional CSS */

/* Prevent modal backdrop from interfering with popups */
.modal-backdrop {
    pointer-events: none !important;
}

.modal-backdrop.show {
    pointer-events: auto !important;
}

/* Enhanced popup styling */
.weight-input-popup {
    position: absolute !important;
    background: white !important;
    border: 3px solid #0d6efd !important;
    border-radius: 10px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25) !important;
    padding: 15px !important;
    z-index: 10000 !important;
    display: none;
    min-width: 200px;
    max-width: 250px;
    pointer-events: auto !important;
    user-select: none;
}

.weight-input-popup * {
    pointer-events: auto !important;
}

.weight-input-popup input {
    pointer-events: auto !important;
    user-select: auto !important;
}

/* Prevent modal from closing when popup is active */
.modal.popup-active {
    pointer-events: none !important;
}

.modal.popup-active .modal-dialog {
    pointer-events: auto !important;
}

.modal.popup-active .modal-content {
    pointer-events: auto !important;
}

/* Enhanced form input protection */
.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus {
    position: relative !important;
    z-index: 1050 !important;
}

/* Popup input specific styles */
#popupWeightInput {
    border: 2px solid #0d6efd !important;
    border-radius: 6px !important;
    text-align: center !important;
    font-size: 1.2rem !important;
    font-weight: bold !important;
    transition: all 0.2s ease !important;
}

#popupWeightInput:focus {
    border-color: #0d6efd !important;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25) !important;
    outline: none !important;
}

#popupWeightInput.valid {
    border-color: #28a745 !important;
    background-color: #f8fff8 !important;
}

#popupWeightInput.invalid {
    border-color: #dc3545 !important;
    background-color: #fff8f8 !important;
}

/* Box card enhancements */
.individual-box-card {
    position: relative;
    transition: all 0.3s ease;
}

.individual-box-card:focus {
    outline: 2px solid #0d6efd !important;
    outline-offset: 2px;
}

.individual-box-card.box-editing {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(13, 110, 253, 0.3);
    border-color: #0d6efd !important;
}

/* Modal enhancements */
.modal-content {
    position: relative;
    overflow: visible;
}

.modal-body {
    position: relative;
    overflow: visible;
}

/* Prevent backdrop clicks during popup */
.modal[data-popup-active="true"] {
    pointer-events: none;
}

.modal[data-popup-active="true"] .modal-dialog {
    pointer-events: auto;
}

/* Loading state for boxes */
.individual-box-card.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Success/Error states */
.popup-success {
    animation: popupSuccess 0.3s ease;
}

.popup-error {
    animation: popupError 0.3s ease;
}

@keyframes popupSuccess {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); background-color: #d4edda; }
    100% { transform: scale(1); }
}

/* Prevent body scrollbar when large modals are open */
body.modal-open {
    overflow: hidden !important;
    padding-right: 0 !important;
}

/* Ensure large modals themselves can scroll */
.modal-dialog.modal-xl .modal-body,
.modal-dialog.modal-lg .modal-body {
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

@keyframes popupError {
    0% { transform: scale(1); }
    25% { transform: translateX(-5px); background-color: #f8d7da; }
    75% { transform: translateX(5px); }
    100% { transform: scale(1); }
}

/* Mobile responsive fixes */
@media (max-width: 768px) {
    .weight-input-popup {
        min-width: 180px;
        padding: 12px;
    }
    
    #popupWeightInput {
        font-size: 1.1rem !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .weight-input-popup {
        border-width: 4px !important;
    }
    
    #popupWeightInput {
        border-width: 3px !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .weight-input-popup,
    .individual-box-card,
    #popupWeightInput {
        transition: none !important;
        animation: none !important;
    }
}
