/* Force BoxNow overlay/popup to the top of the stacking order */
#boxnowmap,
.boxnow-map-widget-overlay,
.boxnow-map-widget-popup,
.boxnow-map-widget,
.boxnow-widget,
.boxnow-popup,
.boxnow-modal,
iframe[src*="boxnow"][src*="map-widget"] {
    z-index: 2147483640 !important; /* near-max */
}

/* Ensure a stacking context exists */
#boxnowmap,
.boxnow-map-widget-overlay,
.boxnow-map-widget-popup,
.boxnow-map-widget,
.boxnow-modal {
    position: relative !important;
}

/* Styles for disabled place order button when BoxNow locker is required but not selected */
button.boxnow-disabled,
input.boxnow-disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    position: relative;
}

button.boxnow-disabled::after,
input.boxnow-disabled::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
}

/* Notice/tooltip that appears above the place order button */
.boxnow-place-order-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 6px;
    color: #856404;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    animation: boxnow-notice-fade-in 0.3s ease-in;
    position: relative;
    width: 100%;
    box-sizing: border-box;
    transition: background-color 0.2s ease;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

.boxnow-place-order-notice:hover,
.boxnow-place-order-notice:active {
    background: #ffe69c !important;
    border-color: #ffb300;
}

.boxnow-place-order-notice:active {
    transform: scale(0.98);
}

.boxnow-place-order-notice .boxnow-notice-icon {
    font-size: 18px;
    flex-shrink: 0;
    line-height: 1;
}

.boxnow-place-order-notice .boxnow-notice-text {
    flex: 1;
    font-weight: 500;
}

@keyframes boxnow-notice-fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .boxnow-place-order-notice {
        padding: 10px 12px;
        font-size: 13px;
        margin-bottom: 10px;
        border-width: 2px;
        touch-action: manipulation; /* Improve touch response */
    }
    
    .boxnow-place-order-notice .boxnow-notice-icon {
        font-size: 16px;
    }
    
    .boxnow-place-order-notice .boxnow-notice-text {
        line-height: 1.4;
    }
    
    /* Larger tap target on mobile */
    .boxnow-place-order-notice:active {
        background: #ffd54f !important;
    }
}

/* Ensure notice is visible on small screens */
@media (max-width: 480px) {
    .boxnow-place-order-notice {
        padding: 10px;
        font-size: 12px;
        gap: 6px;
    }
    
    .boxnow-place-order-notice .boxnow-notice-icon {
        font-size: 14px;
    }
}

/* For Blocks checkout compatibility */
.wc-block-components-checkout-place-order-button ~ .boxnow-place-order-notice,
.place-order ~ .boxnow-place-order-notice {
    margin-bottom: 16px;
}

/* Ensure notice doesn't break layout */
.boxnow-place-order-notice {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}