/**
 * Qualiphy Public Styles
 *
 * Minimal styles that work with WooCommerce default styling.
 * Most styling is inherited from the theme's WooCommerce styles.
 *
 * @package Qualiphy
 * @since 1.0.0
 */

/* ==========================================================================
   Add to Cart Notices (Classic Theme)
   ========================================================================== */

/**
 * Product loop notices for classic themes
 */
.qualiphy-loop-notice {
    display: block;
    font-size: 12px;
    margin-top: 5px;
    line-height: 1.4;
}

/* ==========================================================================
   Add to Cart State (Shared: Block + Classic Themes)
   ========================================================================== */

/**
 * State-based visibility for product buttons.
 * PHP sets data-qualiphy-state, JS updates it on cart changes.
 * States: available, in-cart, rx-limit
 *
 * Works for both:
 * - Block themes: .wp-block-button__link
 * - Classic themes: .button (inside .qualiphy-classic-button)
 */

/* Hide all notices by default */
.qualiphy-product-button .qualiphy-notice {
    display: none;
    font-size: 14px;
    color: #d46262;
    font-weight: bold;
    max-width: 280px;
    margin: 0 auto;
}

/* State: available - show button, hide notices (works for both themes) */
.qualiphy-product-button[data-qualiphy-state="available"] .wp-block-button__link,
.qualiphy-product-button[data-qualiphy-state="available"] > .button,
.qualiphy-product-button[data-qualiphy-state="available"] > a[class*="add_to_cart"] {
    display: inline-block;
}

/* State: in-cart - hide button, show in-cart notice */
.qualiphy-product-button[data-qualiphy-state="in-cart"] .wp-block-button__link,
.qualiphy-product-button[data-qualiphy-state="in-cart"] > .button,
.qualiphy-product-button[data-qualiphy-state="in-cart"] > a[class*="add_to_cart"] {
    display: none !important;
}
.qualiphy-product-button[data-qualiphy-state="in-cart"] .qualiphy-notice--in-cart {
    display: block;
}

/* State: rx-limit - hide button, show rx-limit notice */
.qualiphy-product-button[data-qualiphy-state="rx-limit"] .wp-block-button__link,
.qualiphy-product-button[data-qualiphy-state="rx-limit"] > .button,
.qualiphy-product-button[data-qualiphy-state="rx-limit"] > a[class*="add_to_cart"] {
    display: none !important;
}
.qualiphy-product-button[data-qualiphy-state="rx-limit"] .qualiphy-notice--rx-limit {
    display: block;
}

/* Hide WooCommerce default "View cart" button for Qualiphy products */
.qualiphy-product-button .added_to_cart,
.qualiphy-product-button [data-wp-bind--hidden] {
    display: none !important;
}

/* View cart link within notices */
.qualiphy-notice .qualiphy-view-cart-link {
    display: inline;
    margin-left: 0.25em;
    text-decoration: underline !important;
    font-size: inherit;
    color:inherit;
    font-weight: inherit;
    font-family: inherit;
}

/* Disabled state */
.qualiphy-disabled .qualiphy-notice--disabled {
    display: block;
    color: #666;
}

/* ==========================================================================
   Classic Theme Button Wrapper
   ========================================================================== */

/**
 * Wrapper for classic theme Qualiphy product buttons.
 * Provides consistent display context for state-based visibility.
 */
.qualiphy-classic-button {
    display: inline-block;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

/**
 * Hidden utility class - use instead of inline display:none
 * More theme-friendly and easier to override
 */
.qualiphy-hidden {
    display: none !important;
}

/* ==========================================================================
   Cart Item Exam Message
   ========================================================================== */

/**
 * Exam information in cart
 */
.woocommerce-cart .cart_item .product-name dl.variation dt {
    font-weight: 600;
}

.woocommerce-cart .cart_item .product-name dl.variation dd {
    margin-bottom: 0.5em;
}

/* ==========================================================================
   Exam Refund Message
   ========================================================================== */

/**
 * Refund policy message on cart and checkout pages
 */
.qualiphy-exam-refund-message {
    margin-top: 15px;
    font-size: small;
}

.qualiphy-exam-refund-message p {
    margin: 0;
}

.qualiphy-limit-notice {
    color:#d46262;
    font-weight:bold;
}

.wc-block-components-product-details__qualiphy-rx-exam .wc-block-components-product-details__name{
    display:none;
}
.wc-block-components-product-details__qualiphy-rx-exam .wc-block-components-product-details__value{
    color:#d46262;
    font-weight:bold;
}

.wc-block-components-product-details__qualiphy-non-rx-exam .wc-block-components-product-details__name{
    display:none;
}
.wc-block-components-product-details__qualiphy-non-rx-exam .wc-block-components-product-details__value{
    color:#d46262;
    font-weight:bold;
}

/* Single product page notices - display the notice (overrides hidden default) */
.qualiphy-single-notice .qualiphy-notice {
    display: block;
}

/* ==========================================================================
   Qualiphy Branding
   ========================================================================== */

/**
 * "Powered by Qualiphy" branding under add to cart buttons.
 * Uses IDs for unique identification per product.
 */
.qualiphy-branding {
    display: block;
    width: 100%;
    clear: both;
    font-size: 12px;
    color: #666;
    padding-top: 5px;
    margin-bottom: 0;
}

.qualiphy-branding a {
    color: #3d2b64;
    text-decoration: none;
    font-weight: bold;
    letter-spacing: -0.3px;
}

.qualiphy-branding a:hover {
    text-decoration: underline;
}

/**
 * Screen-reader only class for hidden branding (SEO-friendly).
 * Content remains in DOM for search engine crawling but is
 * visually hidden from users.
 */
.qualiphy-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Exam Launch (Thank-You Page)
   ========================================================================== */

/**
 * Exam launch section displayed on the order-received page
 * after a Qualiphy exam invite is sent.
 */
.qualiphy-exam-launch {
    margin-bottom: 24px;
    padding: 20px 24px;
    background: #f0f0f1;
    border: 1px solid #fff;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.qualiphy-exam-launch__content {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.qualiphy-exam-launch__icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: #e2e0e5;
    color: #1d2327;
    border-radius: 50%;
}

.qualiphy-exam-launch__icon svg {
    width: 24px;
    height: 24px;
}

.qualiphy-exam-launch__info {
    flex: 1 1 0%;
    min-width: 200px;
}

.qualiphy-exam-launch__title {
    margin: 0 0 4px;
    font-size: 1.25em;
    line-height: 1.3;
}

.qualiphy-exam-launch__description {
    margin: 0 0 8px;
    line-height: 1.5;
    color: #4c4c4c;
}

.qualiphy-exam-launch__countdown {
    margin: 0;
    font-size: 14px;
    color: #555;
}

.qualiphy-exam-launch__action {
    flex-shrink: 0;
}

.qualiphy-exam-launch__button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: #53bd6b;
    color: #fff !important;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none !important;
    transition: background 0.2s ease;
}

.qualiphy-exam-launch__button:hover,
.qualiphy-exam-launch__button:focus,
.qualiphy-exam-launch__button:active {
    background: #45a85b;
    color: #fff !important;
    outline: none;
    box-shadow: none;
}

.qualiphy-exam-launch__message {
    margin: 0;
    line-height: 1.5;
}

/* ==========================================================================
   Exam Launch Modal (Popup Mode)
   ========================================================================== */

/**
 * Full-screen modal overlay for the consultation launch popup.
 * Hidden by default, shown via .active class.
 */
.qualiphy-launch-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.qualiphy-launch-modal.active {
    display: flex;
}

.qualiphy-launch-modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
}

.qualiphy-launch-modal__container {
    position: relative;
    background: #fff;
    border-radius: 12px;
    max-width: 440px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/** Placeholder image with loading spinner overlay */
.qualiphy-launch-modal__image-wrapper {
    position: relative;
    width: 100%;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
    background: #e8e0f0;
}

.qualiphy-launch-modal__image {
    display: block;
    width: 100%;
    height: auto;
}

.qualiphy-launch-modal__spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.qualiphy-launch-modal__spinner-text {
    margin: 10px 0 0;
    font-size: 13px;
    color: #fff;
    white-space: nowrap;
}

.qualiphy-launch-modal__spinner-icon {
    display: block;
    margin: 0 auto;
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: qualiphy-modal-spin 0.8s linear infinite;
}

@keyframes qualiphy-modal-spin {
    to { transform: rotate(360deg); }
}

/** Modal body content */
.qualiphy-launch-modal__body {
    padding: 24px 28px;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

.qualiphy-launch-modal__heading {
    margin: 0 0 8px;
    font-size: 1.4em;
    font-weight: 700;
    color: #1a1a1a;
}

.qualiphy-launch-modal__description {
    margin: 0 0 20px;
    font-size: 14px;
    color: #555;
    line-height: 1.5;
}

/** Primary CTA button */
.qualiphy-launch-modal__cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    background: #53bd6b;
    color: #fff !important;
    font-size: 16px;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none !important;
    transition: background 0.2s ease;
    cursor: pointer;
}

.qualiphy-launch-modal__cta-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.qualiphy-launch-modal__cta:hover {
    background: #45a85b;
}

.qualiphy-launch-modal__av-note {
    margin: 14px 0 0;
    font-size: 12px;
    color: #888;
    font-style: italic;
}

.qualiphy-launch-modal__force-redirect {
    margin: 12px 0 0;
    font-size: 13px;
    color: #666;
    text-align: center;
}

/** QR code section — side by side: QR left, text right */
.qualiphy-launch-modal__qr-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: left;
}

.qualiphy-launch-modal__qr-code {
    flex-shrink: 0;
}

.qualiphy-launch-modal__qr-code img {
    display: block;
    border-radius: 4px;
    width: 120px;
    height: 120px;
}

.qualiphy-launch-modal__qr-info {
    flex: 1;
    min-width: 0;
}

.qualiphy-launch-modal__qr-heading {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.qualiphy-launch-modal__qr-description {
    margin: 0;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.qualiphy-launch-modal__email-note {
    margin: 16px 0 0;
    padding-top: 20px;
    border-top: 1px solid #eee;
    font-size: 12px;
    color: #888;
    line-height: 1.4;
}

/** Dismiss link below the modal card */
.qualiphy-launch-modal__dismiss {
    position: relative;
    margin-top: 16px;
    margin-bottom: 16px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8) !important;
    text-decoration: underline !important;
    cursor: pointer;
    transition: color 0.2s ease;
}

.qualiphy-launch-modal__dismiss:hover {
    color: #fff !important;
}

/** Responsive adjustments */
@media (max-width: 480px) {
    .qualiphy-launch-modal__container {
        max-width: 95%;
        border-radius: 8px;
    }

    .qualiphy-launch-modal__image-wrapper {
        border-radius: 8px 8px 0 0;
    }

    .qualiphy-launch-modal__body {
        padding: 20px 16px;
    }

    .qualiphy-launch-modal__cta {
        width: 100%;
        box-sizing: border-box;
        text-align: center;
    }

    .qualiphy-launch-modal__qr-section {
        flex-direction: column;
        text-align: center;
    }
}