/* ----- Apple system font stack ----- */
body, button, input, .product_title, .price, .wc-var-btn span, .single_add_to_cart_button {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ----- Product meta (tight) ----- */
.product_meta {
    display: flex !important;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px !important;
    padding: 10px 14px !important;
    background: #ffffff;
    border: 1px solid #e8e8ed;
    border-radius: 14px;
    box-shadow: 0 1px 1px rgba(0,0,0,.02);
}
.product_meta > span {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f9f9fb;
    border: 1px solid #ececf0;
    border-radius: 30px;
    padding: 4px 12px;
    margin: 0 !important;
    color: #1d1d1f;
    font-weight: 500;
    font-size: 12px;
}
.product_meta a {
    color: #1d1d1f !important;
    text-decoration: none !important;
    font-weight: 600;
}
.product-short-description {
    margin-top: 20px;
}
.price-placeholder {
    color: #6e6e73;
}

/* ----- Typography (compact) ----- */
.product_title {
    font-size: 24px !important;
    line-height: 1.25 !important;
    font-weight: 600 !important;
    letter-spacing: -0.2px;
    color: #1d1d1f !important;
    margin: 0 0 4px 0 !important;
}
.single-product .price {
    font-size: 20px !important;
    font-weight: 700 !important;
    color: #1d1d1f !important;
    margin: 2px 0 16px !important;
    letter-spacing: -0.2px;
}
.single-product .price del {
    color: #8e8e93;
    font-size: 20px;
    font-weight: 500;
    margin-right: 6px;
}
.single-product .price ins {
    text-decoration: none;
    background: none;
    color: #1d1d1f;
    font-weight: 700;
}

/* ----- Purchase card (minimal padding) ----- */
.single-product .cart {
    background: #ffffff !important;
    border-radius: 16px !important;
    padding: 14px 16px !important;
    border: 1px solid #e8e8ed;
    box-shadow: 0 1px 2px rgba(0,0,0,.02), 0 4px 12px rgba(0,0,0,.02);
    display: flex;
    flex-direction: column;
}
.purchase-actions-desktop {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
    order: 3;
}
.single-product .cart .variations {
    order: 1;
    width: 100%;
    margin: 0 0 12px 0 !important;
}
.single-product .cart .stock.out-of-stock {
    order: 2;
}

/* ----- Quantity stepper (desktop) ----- */
.single-product .quantity {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 120px !important;
    height: 48px !important;
    background: #ffffff !important;
    border: 1px solid #d2d2d7 !important;
    border-radius: 10px !important;
    overflow: hidden !important;
}
.single-product .quantity button.minus,
.single-product .quantity button.plus {
    width: 40px !important;
    height: 48px !important;
    border: none !important;
    background: #f5f5f7 !important;
    font-size: 22px !important;
    font-weight: 500 !important;
    color: #1d1d1f !important;
    cursor: pointer !important;
    padding: 0;
    line-height: 1;
}
.single-product .quantity input.qty {
    width: 40px !important;
    height: 48px !important;
    border: none !important;
    background: #fff !important;
    text-align: center !important;
    font-size: 17px !important;
    font-weight: 500 !important;
    color: #1d1d1f !important;
    padding: 0 !important;
    margin: 0 !important;
    -moz-appearance: textfield;
}

/* ----- Add to Cart button (desktop) ----- */
.single-product .single_add_to_cart_button,
.single-product button.single_add_to_cart_button {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    height: 48px !important;
    padding: 0 20px !important;
    background: #1d1d1f !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 10px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    letter-spacing: -0.2px;
    white-space: nowrap;
    cursor: pointer;
}

/* ----- Out of stock pill ----- */
.single-product .cart .stock.out-of-stock {
    display: inline-flex !important;
    align-items: center !important;
    font-size: 13px !important;
    color: #b81c1c !important;
    font-weight: 500 !important;
    background: #fef2f2 !important;
    padding: 5px 14px !important;
    border-radius: 30px !important;
    margin: 0 !important;
    border: 1px solid #fee2e2 !important;
    width: fit-content;
}
.single-product .summary .stock.in-stock {
    color: #1d1d1f !important;
    font-weight: 500 !important;
}

/* ----- Variation buttons ----- */
.variations select.wc-native-hidden {
    position: absolute !important;
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
}
.variations {
    border: none !important;
    margin: 0 !important;
}
.variations tr {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0 0 12px;
}
.variations td, .variations th {
    padding: 0 !important;
    border: none !important;
}
.variations label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #6e6e73;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.wc-var-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 100%;
}
.wc-var-btn {
    width: 72px !important;
    height: 72px !important;
    padding: 6px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    background: #fff;
    border: 1px solid #d2d2d7;
    border-radius: 12px !important;
    cursor: pointer;
    box-sizing: border-box;
    flex: 0 0 auto;
}
.wc-var-btn.active {
    background: #1d1d1f;
    border-color: #1d1d1f;
}
.wc-var-btn img {
    width: 34px !important;
    height: 34px !important;
    object-fit: cover;
    border-radius: 8px;
    background: #f5f5f7;
    display: block;
}
.wc-var-btn span {
    font-size: 10px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    max-width: 64px;
    color: #1d1d1f;
    text-transform: uppercase;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wc-var-btn.active span {
    color: #fff;
}
.wc-var-btn.no-image {
    width: auto !important;
    height: 42px !important;
    min-width: 68px;
    padding: 0 14px !important;
    border-radius: 30px !important;
    gap: 0;
}
.wc-var-btn.no-image span {
    max-width: none;
    font-size: 13px;
    line-height: 1;
    font-weight: 500;
    text-transform: none;
}
.wc-var-btn.disabled {
    opacity: 0.5;
    cursor: default;
    background: #f5f5f7;
}
.wc-var-btn:hover:not(.active):not(.disabled) {
    background: #f5f5f7 !important;
    border-color: #a1a1a6 !important;
}

/* ----- Responsive: Tablet & Mobile (≤1024px) ----- */
@media (max-width: 1024px) {
    /* Horizontal scroll for variation buttons */
    .variations, .variations tbody, .variations tr, .variations td, .variations th {
        display: block;
        width: 100%;
    }
    .wc-var-wrap {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        gap: 8px;
        padding: 2px 0 6px;
        scrollbar-width: none;
    }
    .wc-var-wrap::-webkit-scrollbar {
        display: none;
    }
    /* Smaller variation buttons on mobile/tablet */
    .wc-var-btn {
        flex: none !important;
        width: 64px !important;
        height: 64px !important;
    }
    .wc-var-btn img {
        width: 30px !important;
        height: 30px !important;
    }
    .wc-var-btn span {
        font-size: 9px !important;
    }
    .wc-var-btn.no-image {
        height: 40px !important;
        min-width: 58px !important;
        padding: 0 12px !important;
    }
    .wc-var-btn.no-image span {
        font-size: 12px !important;
    }

    /* Typography adjustments */
    .product_title {
        font-size: 22px !important;
    }
    body.single-product {
        padding-bottom: 80px !important;
    }

    /* Hide original quantity & button, show sticky bar */
    .single-product .cart .quantity,
    .single-product .cart .single_add_to_cart_button,
    .purchase-actions-desktop {
        display: none !important;
    }

    /* STICKY BAR (40/30/30) */
    .torfy-mobile-sticky-bar {
        position: fixed !important;
        bottom: 0 !important;
        left: 1% !important;
        right: 1% !important;
        width: 98% !important;
        z-index: 9999 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 10px 12px !important;
        background: rgba(255,255,255,.97) !important;
        backdrop-filter: blur(20px);
        border: 1px solid rgba(0,0,0,.06) !important;
        border-radius: 18px 18px 0 0 !important;
        box-shadow: 0 -4px 20px rgba(0,0,0,.06), 0 -1px 3px rgba(0,0,0,.04);
        box-sizing: border-box !important;
        gap: 8px !important;
    }
    .torfy-mobile-price {
        flex: 0 0 33.33% !important;
        max-width: 33.33% !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        line-height: 1 !important;
    }
    .torfy-mobile-price del {
        color: #9ca3af !important;
        font-size: 13px !important;
        font-weight: 500 !important;
        text-decoration-thickness: 1px !important;
        margin: 0 !important;
    }
    .torfy-mobile-price ins {
        color: #111827 !important;
        font-size: 24px !important;
        font-weight: 800 !important;
        text-decoration: none !important;
        margin: 0 !important;
    }
    .torfy-mobile-price > .woocommerce-Price-amount,
    .torfy-mobile-price > bdi {
        color: #111827 !important;
        font-size: 24px !important;
        font-weight: 800 !important;
    }
    .torfy-mobile-actions {
        flex: 0 0 66.66% !important;
        max-width: 66.66% !important;
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
    }
    .torfy-mobile-actions .quantity {
        flex: 1 !important;
        width: auto !important;
        min-width: 0 !important;
        height: 46px !important;
    }
    .torfy-mobile-actions .quantity button {
        width: 34px !important;
        height: 46px !important;
        font-size: 18px !important;
    }
    .torfy-mobile-actions .quantity input.qty {
        width: 34px !important;
        height: 46px !important;
        font-size: 15px !important;
    }
    .torfy-mobile-actions .single_add_to_cart_button {
        flex: 1 !important;
        height: 46px !important;
        min-width: 0 !important;
        border-radius: 12px !important;
        font-size: 14px !important;
        font-weight: 700 !important;
        white-space: nowrap !important;
        text-align: center !important;
    }
}

/* Extra small screens (≤480px) */
@media (max-width: 480px) {
    .torfy-mobile-price {
        font-size: 16px !important;
    }
    .torfy-mobile-actions .single_add_to_cart_button {
        font-size: 12px !important;
        padding: 0 6px !important;
    }
    .torfy-mobile-actions .quantity button {
        width: 32px !important;
        font-size: 18px !important;
    }
}

/* Accessibility */
button:focus-visible,
.wc-var-btn:focus-visible,
.single_add_to_cart_button:focus-visible {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}
