/* wpcbd-frontend.css */

/* Image Blurring and gallery hiding */
.wpcbd-single-locked .woocommerce-product-gallery__image,
li.wpcbd-locked-product a img {
    filter: blur(12px) grayscale(50%) !important;
    pointer-events: none;
    transition: filter 0.5s ease;
}

.wpcbd-single-locked .woocommerce-product-gallery .flex-control-nav,
.wpcbd-single-locked .woocommerce-product-gallery .woocommerce-product-gallery__trigger {
    display: none !important;
}

/* Image Overlay for loop items */
li.wpcbd-locked-product a.woocommerce-LoopProduct-link {
    position: relative;
    display: block;
}

.wpcbd-image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; /* Fills the container, which will be the <a> tag */
    display: none !important; /* Hidden until JS moves it inside the <a> tag */
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
    padding: 20px;
    box-sizing: border-box;
}

/* Only show overlay when it's inside an <a> tag (moved by JS) AND the product is still locked */
li.wpcbd-locked-product a .wpcbd-image-overlay {
    display: flex !important;
}

.wpcbd-overlay-content {
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    text-align: center;
    font-size: 0.9em;
    font-weight: 600;
    line-height: 1.4;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    backdrop-filter: blur(4px);
    max-width: 90%;
    /* Flex alignment to guarantee vertical centering */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.wpcbd-overlay-content p {
    margin: 0 !important;
    padding: 0 !important;
}

.wpcbd-overlay-content small {
    font-size: 0.8em;
    opacity: 0.8;
    font-weight: normal;
}

/* Badge Styling */
.wpcbd-lock-badge {
    display: inline-flex;
    align-items: center;
    background: #e74c3c;
    color: #fff;
    font-size: 0.85em;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 10px;
    margin-right: 10px;
    vertical-align: middle;
}

.wpcbd-lock-badge.wpcbd-unlocked-badge {
    background: #2ecc71; /* Green color to indicate success/unlocked */
    color: #fff;
}

.wpcbd-lock-badge svg {
    margin-right: 5px;
    fill: currentColor;
}

/* Unlock Container */
.wpcbd-unlock-container {
    background-color: #f8f9fa !important;
    border: 1px solid #e2e8f0 !important;
    padding: 30px !important;
    border-radius: 10px !important;
    margin: 30px 0 !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05) !important;
}

.wpcbd-unlock-info, .wpcbd-unlock-info p {
    font-size: 0.95em !important;
    color: #4a5568 !important;
    margin-bottom: 20px !important;
    line-height: 1.6 !important;
}

.wpcbd-unlock-info p:last-child {
    margin-bottom: 0 !important;
}

.wpcbd-unlock-form {
    display: flex;
    flex-direction: column;
}

.wpcbd-unlock-form label {
    font-weight: 600 !important;
    margin-bottom: 10px !important;
    display: block !important;
    color: #2d3748 !important;
}

.wpcbd-input-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

@media (max-width: 500px) {
    .wpcbd-input-group {
        flex-direction: column;
        align-items: stretch;
    }
    .wpcbd-input-group button {
        width: 100%;
    }
}

.wpcbd-input-group input[type="text"] {
    flex: 1;
    height: 50px !important;
    min-height: 50px !important;
    padding: 0 16px !important;
    font-size: 16px !important;
    background-color: #ffffff !important;
    color: #1a202c !important;
    border: 1px solid #cbd5e0 !important;
    border-radius: 6px !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05) !important;
}

.wpcbd-input-group input[type="text"]::placeholder {
    color: #a0aec0 !important;
}

.wpcbd-input-group input[type="text"]:focus {
    border-color: #3182ce !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.15) !important;
}

.wpcbd-input-group button {
    margin: 0 !important;
    height: 50px !important;
    min-height: 50px !important;
    padding: 0 28px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 6px !important;
    box-sizing: border-box !important;
    font-weight: 600 !important;
    line-height: 1 !important;
}

/* Loading State */
.wpcbd-input-group button.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
    color: transparent !important;
}

.wpcbd-input-group button.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    border: 3px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: wpcbd-spin 1s ease infinite;
}

@keyframes wpcbd-spin {
    from { transform: rotate(0turn); }
    to { transform: rotate(1turn); }
}

/* Messages */
.wpcbd-message {
    margin-top: 15px;
    font-size: 0.9em;
    font-weight: 500;
    display: none;
    padding: 10px;
    border-radius: 6px;
}

.wpcbd-message.error {
    display: block;
    background: #fdf0ed;
    color: #e74c3c;
    border: 1px solid #fadbd8;
}

.wpcbd-message.success {
    display: block;
    background: #edf7ed;
    color: #2ecc71;
    border: 1px solid #d5f5e3;
}


/* Skeleton Loading for AJAX Replacement */
.wpcbd-skeleton {
    animation: wpcbd-skeleton-loading 1s linear infinite alternate;
    background: #eee;
    border-radius: 4px;
    height: 20px;
    margin-bottom: 10px;
}
.wpcbd-skeleton.btn {
    height: 45px;
    width: 150px;
}

@keyframes wpcbd-skeleton-loading {
    0% { background-color: hsl(200, 20%, 90%); }
    100% { background-color: hsl(200, 20%, 95%); }
}
