/* =====================================================
   OM Artisan Quickview — Modal
   ===================================================== */

/* Trigger button */
.om-quickview-btn {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    cursor: pointer;
    background-color: #323232!important;
    z-index: 999;
    position: absolute;
    top: 10px;
    right: 10px;
    transition: opacity 0.3s ease;
    color: white;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 1px;
    padding: 5px 8px!important;
    display: flex;
    align-items: center;
    border-radius: 50px!important;
    line-height: 13px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    
    .quickview-button-text {
        display: none;

        padding-top: 2px;
        padding-right: 4px;
    }
    
    .quickview-button-icon {
        width: 13px;
        color: white;
        display: block;
    }
    
    @media (min-width: 768px) {
        opacity: 0;
    
        padding: 8px 12px!important;
    
        .quickview-button-text {
            display: block;
        }
    
        .quickview-button-icon {
            display: none;
        }
    }
}

/* Ensure image wrappers are positioned so the absolute button renders correctly */
.wc-block-grid__product-image,
.wc-block-components-product-image {
    position: relative;
}

/* Reveal button on hover of the product card (desktop only) */
@media (min-width: 768px) {
    .wc-block-grid__product:hover .om-quickview-btn,
    .wc-block-product:hover .om-quickview-btn,
    .product:hover .om-quickview-btn {
        opacity: 1;
    }
}

.om-quickview-btn:hover {
    opacity: 0.7 !important;
}

/* Modal base — hidden by default */
.om-quickview-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100000;
}

.om-quickview-modal.is-open,
.om-quickview-modal.is-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 0;
}

/* Overlay / backdrop */
.om-quickview-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    cursor: pointer;
}

/* Centred container */
.om-quickview-container {
    position: relative;
    background: #fff;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    max-height: 85dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 4px;
    padding: 40px 32px 32px;
    box-sizing: border-box;
    flex-shrink: 0;
    margin: auto;
}

/* Close button */
.om-quickview-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: inherit;
    padding: 4px 8px;
    z-index: 1;
}

.om-quickview-close:hover {
    opacity: 0.6;
}

/* Loading spinner placeholder */
.om-quickview-modal.is-loading .om-quickview-body::after {
    content: '';
    display: block;
    width: 36px;
    height: 36px;
    margin: 60px auto;
    border: 3px solid #eee;
    border-top-color: #333;
    border-radius: 50%;
    animation: om-quickview-spin 0.7s linear infinite;
}

@keyframes om-quickview-spin {
    to { transform: rotate(360deg); }
}

/* Error state */
.om-quickview-error {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

/* Body scroll lock */
body.om-quickview-open {
    overflow: hidden;
}

/* =====================================================
   Product content layout inside modal
   ===================================================== */

.om-quickview-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    align-items: start;
}

.om-quickview-gallery {
    position: relative;
}

.om-quickview-featured-image {
    width: 100%;
    height: auto;
    display: block;
}

.om-quickview-summary {
    padding: 0;
}

.single_variation_wrap {
    min-height: 180px;
}
/* Price — 60px matching single product page */
#om-quickview-modal .woocommerce-Price-amount.amount,
#om-quickview-modal del,
#om-quickview-modal ins {
    font-size: 60px;
}

#om-quickview-modal .price,
#om-quickview-modal .woocommerce-variation-price {
    min-height: 66px;
    margin-bottom: 8px;
    display: block;
    line-height: 1.1;
}

/* Excerpt — reduce bottom margin */
#om-quickview-modal .woocommerce-product-details__short-description {
    margin-bottom: 8px;
}

/* "Gå till produkten" link */
.om-quickview-product-link {
    display: inline-block;
    font-size: 13px;
    color: inherit;
    opacity: 0.55;
    text-decoration: underline;
    margin-bottom: 16px;
}

.om-quickview-product-link:hover {
    opacity: 0.85;
}


/* Variation label — hide label inside table */
#om-quickview-modal .variations label[for=pa_storlek] {
    display: none;
}

#om-quickview-modal .variations::before {
    content: "Välj storlek:";
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
}

/* Variations table — no extra padding */
#om-quickview-modal .variations {
    width: 100%;
    border: none;
    margin-bottom: 4px;
}

#om-quickview-modal .variations td,
#om-quickview-modal .variations th {
    padding: 0 0 8px;
    border: none;
    vertical-align: top;
}

#om-quickview-modal .variations td.label {
    width: auto;
    white-space: nowrap;
    padding-right: 12px;
}

/* Add to cart wrapper */
#om-quickview-modal .woocommerce-variation-add-to-cart,
#om-quickview-modal .quickview-simple-product form {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5em;
}

/* Custom quantity stepper */
.om-quantity-wrap {
    display: flex;
    align-items: center;
    gap: 0;
    height: 45px;
    border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
    border-radius: 4px;
}

.om-quantity-wrap .om-qty-btn {
    width: 36px;
    height: 45px;
    background: none;
    border-radius: 2px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
}

.om-quantity-wrap .om-qty-btn:hover {
    background-color: color-mix(in srgb, currentColor 8%, transparent);
}

.om-quantity-wrap input.qty {
    width: 48px;
    height: 45px;
    text-align: center;
    border: none;
    border-left: none;
    border-right: none;
    border-radius: 0;
    font-size: 14px;
    -moz-appearance: textfield;
    appearance: textfield;
}

.om-quantity-wrap input.qty::-webkit-outer-spin-button,
.om-quantity-wrap input.qty::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#om-quickview-modal .quantity:not(.om-quantity-wrap) {
    display: inline-block;
}


#om-quickview-modal .single_add_to_cart_button {
    height: 45px;
    align-items: center;
    border-style: none;
    display: inline-flex;
    justify-content: center;
    line-height: inherit;
    overflow: hidden;
    white-space: normal;
    word-break: normal;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 1px;
    border-radius: 4px;
}

#om-quickview-modal .added_to_cart.wc-forward {
    display: none !important;
}

/* =====================================================
   Variation pill buttons (label + hidden radio, mirrors WC block pill pattern)
   ===================================================== */

.om-variation-pills {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
}

.om-variation-pill {
    --pill-color: currentColor;
    --pill-background-color: transparent;
    background-color: var(--pill-background-color);
    border: 1px solid color-mix(in srgb, var(--pill-color) 40%, transparent);
    border-radius: 2px;
    color: var(--pill-color);
    cursor: pointer;
    font-size: 0.85em;
    padding: 0.25em 0.75em;
    user-select: none;
}

/* Hide the radio input visually but keep it accessible */
.om-variation-pill-input {
    appearance: none;
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.om-variation-pill label {
    cursor: pointer;
}

/* Selected state — dark fill, same as WC block pill */
.om-variation-pill:has(.om-variation-pill-input:checked) {
    --pill-background-color: var(--wp--preset--color--primary, #1a1a1a);
    color: #fff;
    border-color: var(--pill-background-color);
}

/* Hover on unselected */
.om-variation-pill:not(:has(.om-variation-pill-input:disabled)):hover {
    background-color: color-mix(in srgb, var(--pill-color) 10%, transparent);
}

/* Hover on selected */
.om-variation-pill:hover:has(.om-variation-pill-input:checked) {
    background-color: color-mix(in srgb, var(--pill-background-color) 85%, transparent);
}

/* Focus ring */
.om-variation-pill:has(.om-variation-pill-input:focus-visible) {
    outline: 1px solid var(--pill-color);
    outline-offset: 1px;
}

/* Disabled state */
.om-variation-pill:has(.om-variation-pill-input:disabled) {
    color: color-mix(in srgb, var(--pill-color) 40%, transparent);
    cursor: not-allowed;
    text-decoration: line-through;
}

/* =====================================================
   Add-to-cart button states (mirrors theme add-to-cart.php)
   ===================================================== */

#om-quickview-modal .single_add_to_cart_button.adding-to-cart {
    opacity: 0.7;
}

#om-quickview-modal .single_add_to_cart_button.added-to-cart {
    background-color: #218838 !important;
    border-color: #218838 !important;
    color: white !important;
    position: relative;
}

#om-quickview-modal .single_add_to_cart_button.added-to-cart:hover {
    background-color: #166b29 !important;
    border-color: #166b29 !important;
}

#om-quickview-modal .single_add_to_cart_button.added-to-cart::after {
    content: '';
    display: inline-block;
    width: 7px;
    height: 12px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    animation: om-checkmark-appear 0.3s ease-in-out;
    margin-left: 11px;
    margin-bottom: 4px;
    vertical-align: middle;
}

#om-quickview-modal .single_add_to_cart_button.resetting-to-cart {
    animation: om-reset-to-default 0.3s ease-out forwards;
}

@keyframes om-checkmark-appear {
    0%   { opacity: 0; transform: rotate(45deg) scale(0.5); }
    100% { opacity: 1; transform: rotate(45deg) scale(1); }
}

@keyframes om-reset-to-default {
    0%   { background-color: #218838; border-color: #218838; transform: scale(1); }
    50%  { transform: scale(0.95); }
    100% { background-color: var(--wp--preset--color--primary, #000); border-color: var(--wp--preset--color--primary, #000); transform: scale(1); }
}

/* =====================================================
   Toast notification (shared with theme add-to-cart.php)
   ===================================================== */

#om-quickview-modal .reset_variations {
    display: none !important;
}

.om-cart-toast {
    position: fixed;
    top: 88px;
    right: 20px;
    background-color: #218838;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 3px 4px 12px rgba(0, 0, 0, 0.45);
    z-index: 999999 !important;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    animation: om-toast-slide-in 0.3s ease-out;
}

@media (max-width: 768px) {
    #om-quickview-modal .om-cart-toast {
        top: 106px;
        right: 16px;
    }
}

#om-quickview-modal .om-toast-message {
    flex: 1;
}

#om-quickview-modal .om-toast-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

#om-quickview-modal .om-toast-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

#om-quickview-modal .om-toast-fade-out {
    animation: om-toast-fade-out 0.3s ease-in forwards;
}

@keyframes om-toast-slide-in {
    0%   { opacity: 0; transform: translateX(20px); }
    100% { opacity: 1; transform: translateX(0); }
}

@keyframes om-toast-fade-out {
    0%   { opacity: 1; transform: translateX(0); }
    100% { opacity: 0; transform: translateX(20px); }
}

/* =====================================================
   Responsive
   ===================================================== */

@media (max-width: 640px) {
    .om-quickview-container {
        padding: 48px 20px 24px;
    }

    .om-quickview-layout {
        grid-template-columns: 1fr;
    }
}
