/* --- Checkout Popup System --- */
.opsim-checkout-popup-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000000; /* Extremely high z-index to stay above everything else (including cart drawer) */
    display: none;
    padding: 40px 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.opsim-checkout-popup-wrapper.active {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.opsim-checkout-popup-wrapper .opsim-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: -1;
}

.opsim-checkout-popup-wrapper .opsim-popup-container {
    position: relative;
    background: #fff;
    width: 100%;
    max-width: 500px;
    margin: auto;
    border-radius: 12px;
    border: 2px solid var(--opsim-brand, #355872); /* 2px Brand Border */
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    animation: opsim-popup-slide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1;
    overflow: hidden;
}

/* Clean Top Bar with Title */
.opsim-popup-top-bar {
    width: 100%;
    background-color: transparent; /* Removed red background */
    padding: 8px 12px; /* Reduced padding */
    text-align: center;
    border-radius: 10px 10px 0 0;
}

.opsim-popup-top-bar h2 {
    color: var(--opsim-brand, #355872) !important; /* Changed to brand color */
    font-size: 0.85rem !important; /* Slightly smaller */
    font-weight: 800 !important;
    margin: 0 !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@keyframes opsim-popup-slide {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.opsim-checkout-popup-wrapper .opsim-popup-close {
    position: absolute;
    top: 8px; /* Adjusted */
    right: 15px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #333; /* Dark color for white background */
    z-index: 10;
    transition: opacity 0.2s;
}

.opsim-checkout-popup-wrapper .opsim-popup-close:hover {
    opacity: 0.7;
}

.opsim-checkout-popup-wrapper .opsim-popup-content {
    padding: 24px;
    padding-top: 5px; /* Reduced top padding */
}

.opsim-checkout-popup-wrapper .opsim-popup-header {
    margin-bottom: 0; /* Reduced space */
    text-align: center;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0; /* Full-width Divider */
    margin-left: -24px; /* Counter-act parent padding to make it full width */
    margin-right: -24px;
}

.opsim-checkout-popup-wrapper .opsim-popup-header p {
    font-size: 0.75rem;
    color: #6b7280;
    margin: 0;
    margin-top: -2px; /* Pull closer to the main title */
}

/* Product Summary in Popup */
.opsim-checkout-popup-wrapper .opsim-popup-product-summary {
    background: transparent;
    padding: 0;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.opsim-checkout-popup-wrapper .opsim-summary-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.opsim-checkout-popup-wrapper .opsim-summary-item:last-child {
    border-bottom: none;
}

.opsim-checkout-popup-wrapper .opsim-item-image {
    width: 45px;
    height: 45px;
    border-radius: 6px;
    position: relative;
    border: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.opsim-checkout-popup-wrapper .opsim-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.opsim-checkout-popup-wrapper .opsim-item-qty-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 16px;
    height: 16px;
    background: var(--opsim-brand, #355872);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #fff;
}

.opsim-checkout-popup-wrapper .opsim-item-info {
    flex: 1;
}

.opsim-checkout-popup-wrapper .opsim-item-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 1px 0;
}

.opsim-checkout-popup-wrapper .opsim-item-price {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--opsim-brand, #355872);
}

.opsim-checkout-popup-wrapper .opsim-remove-summary-item {
    background: transparent;
    border: none;
    color: #d1d5db;
    cursor: pointer;
    padding: 5px;
    font-size: 16px;
}

.opsim-checkout-popup-wrapper .opsim-remove-summary-item:hover {
    color: #111827;
}

.opsim-checkout-popup-wrapper .opsim-popup-total-bar {
    display: none;
}

/* Form Styles Override */
.opsim-checkout-popup-wrapper .opsim-popup-form-container .opsim-modular-checkout-wrapper {
    border: none;
    padding: 0;
    background: transparent;
    margin-top: 0;
}

.opsim-checkout-popup-wrapper .opsim-popup-form-container .opsim-checkout-header {
    display: none;
}

@media (max-width: 500px) {
    .opsim-checkout-popup-wrapper {
        padding: 20px 10px; /* Small gap on sides */
        display: none; /* Keep hidden by default */
        align-items: center; /* Center vertically if content is small */
    }
    .opsim-checkout-popup-wrapper.active {
        display: flex; /* Show only when active */
    }
    .opsim-checkout-popup-wrapper .opsim-popup-container {
        margin: auto;
        min-height: auto; /* Not full height */
        max-height: 90vh; /* Allow scrolling within 90% of screen */
        border-radius: 12px;
        border: 2px solid var(--opsim-brand, #355872);
        overflow-y: auto;
    }
}
