/**
 * WooCommerce Advanced Product Widget - Frontend Styles
 * Version: 2.1.0
 */

/* ── Container ─────────────────────────────────────────── */
.wc-apw-container {
    position: relative;
    width: 100%;
}

/* ══════════════════════════════════════════════════════════
   VARIATION SELECTORS
   ══════════════════════════════════════════════════════════ */

.wc-apw-variations-area {
    width: 100%;
    margin-bottom: 16px;
}

/* Hide the JSON data tag */
.wc-apw-variations-json { display: none; }

/* Each attribute row (Color, Size, etc.) */
.wc-apw-variation-wrapper {
    margin-bottom: 16px;
}

/* ── Attribute Label ── */
.wc-apw-var-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.wc-apw-var-label-inline {
    display: inline-block;
    margin-bottom: 0;
    margin-right: 10px;
    vertical-align: middle;
}

/* Options flex wrap */
.wc-apw-var-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* ── Button / Swatch ──────────────────────────────────── */
.wc-apw-var-option-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    padding: 8px 14px;
    background-color: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .2s, color .2s, border-color .2s, transform .1s;
    line-height: 1.3;
    user-select: none;
}

.wc-apw-var-option-btn:hover:not(:disabled):not(.wc-apw-var-disabled) {
    background-color: #e8e8e8;
    border-color: #999;
    color: #000;
}

.wc-apw-var-option-btn:active:not(:disabled) {
    transform: scale(.95);
}

.wc-apw-var-option-btn.wc-apw-var-selected {
    background-color: #333;
    color: #fff;
    border-color: #333;
}

/* ── Radio ────────────────────────────────────────────── */
.wc-apw-var-radio-wrapper {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

/* Visually hide native radio */
.wc-apw-var-radio-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border-width: 0;
}

.wc-apw-var-radio-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    background: transparent;
    cursor: pointer;
    transition: border-color .2s, color .2s;
    user-select: none;
}

.wc-apw-var-radio-label:hover {
    border-color: #999;
}

.wc-apw-var-radio-input:checked + .wc-apw-var-radio-label,
.wc-apw-var-radio-label.wc-apw-var-radio-checked {
    border-color: #333;
    color: #fff;
    background-color: #333;
}

/* ── Image Swatch ─────────────────────────────────────── */
.wc-apw-var-image-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border: 2px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    padding: 0;
    background: #f5f5f5;
    transition: border-color .2s, outline .15s;
    position: relative;
}

.wc-apw-var-image-swatch img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: inherit;
}

.wc-apw-var-image-swatch .wc-apw-var-swatch-text {
    font-size: 11px;
    font-weight: 600;
    color: #333;
    text-align: center;
    word-break: break-word;
    padding: 2px 3px;
    line-height: 1.2;
}

.wc-apw-var-image-swatch:hover:not(:disabled):not(.wc-apw-var-disabled) {
    border-color: #999;
}

.wc-apw-var-image-swatch.wc-apw-var-selected {
    outline: 2px solid #333;
    outline-offset: 2px;
    border-color: #333;
}

/* ── Dropdown ─────────────────────────────────────────── */
.wc-apw-var-select {
    display: block;
    width: 100%;
    padding: 10px 36px 10px 14px;
    background-color: #fff;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 400;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
    transition: border-color .2s;
}

.wc-apw-var-select:focus {
    outline: none;
    border-color: #999;
}

/* ── Out of Stock States ──────────────────────────────── */

/* Strikethrough */
.wc-apw-var-oos-strikethrough .wc-apw-var-option-btn,
.wc-apw-var-oos-strikethrough .wc-apw-var-radio-label,
.wc-apw-var-oos-strikethrough .wc-apw-var-image-swatch {
    position: relative;
    opacity: 0.65;
    cursor: not-allowed;
}

.wc-apw-var-oos-strikethrough .wc-apw-var-option-btn::after,
.wc-apw-var-oos-strikethrough .wc-apw-var-radio-label::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 8%;
    width: 84%;
    height: 1.5px;
    background-color: currentColor;
    opacity: 0.7;
    transform: translateY(-50%) rotate(-10deg);
    pointer-events: none;
}

/* Image swatch OOS — diagonal line overlay */
.wc-apw-var-oos-strikethrough .wc-apw-var-image-swatch::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top right,
        transparent calc(50% - 1px),
        rgba(200, 60, 60, 0.75) calc(50% - 1px),
        rgba(200, 60, 60, 0.75) calc(50% + 1px),
        transparent calc(50% + 1px)
    );
    pointer-events: none;
    border-radius: inherit;
}

/* Greyed out / Disabled */
.wc-apw-var-oos-disabled .wc-apw-var-option-btn,
.wc-apw-var-oos-disabled .wc-apw-var-radio-label,
.wc-apw-var-oos-disabled .wc-apw-var-image-swatch {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Quantity ──────────────────────────────────────────── */
.wc-apw-quantity-wrapper {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.wc-apw-quantity-label {
    margin-right: 10px;
    font-size: 16px;
    font-weight: 400;
    white-space: nowrap;
}

.wc-apw-quantity-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wc-apw-qty-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    font-size: 20px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .2s, color .2s;
    user-select: none;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

.wc-apw-qty-button:hover:not(:disabled) {
    background-color: #e0e0e0;
    color: #000;
}

.wc-apw-qty-button:active:not(:disabled) {
    transform: scale(.94);
}

.wc-apw-qty-button:disabled {
    opacity: .4;
    cursor: not-allowed;
}

.wc-apw-qty-input {
    width: 60px;
    height: 40px;
    text-align: center;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    background-color: #fff;
    color: #000;
    -moz-appearance: textfield;
}

.wc-apw-qty-input::-webkit-outer-spin-button,
.wc-apw-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.wc-apw-qty-input:focus {
    outline: none;
    border-color: #999;
}

/* ── Button Grid ───────────────────────────────────────── */
.wc-apw-buttons-wrapper {
    display: grid;
    width: 100%;
    gap: 12px;
}

.wc-apw-buttons-wrapper.layout-2-column {
    grid-template-columns: 1fr 1fr;
}

.wc-apw-buttons-wrapper.layout-stack {
    grid-template-columns: 1fr;
}

.wc-apw-buttons-wrapper.layout-inline {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

/* ── Button Base ───────────────────────────────────────── */
.wc-apw-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    cursor: pointer;
    transition: background-color .25s, transform .2s, box-shadow .25s;
    position: relative;
    overflow: hidden;
    gap: 8px;
    white-space: nowrap;
}

.wc-apw-button:focus-visible {
    outline: 3px solid rgba(0,0,0,.3);
    outline-offset: 2px;
}

.wc-apw-button:disabled {
    opacity: .5;
    cursor: not-allowed;
    pointer-events: none;
}

.wc-apw-button i,
.wc-apw-button svg:not(.wc-apw-spinner-svg) {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    font-size: 1em;
    width: 1em;
    height: 1em;
    line-height: 1;
}

.wc-apw-button.icon-before i,
.wc-apw-button.icon-before svg:not(.wc-apw-spinner-svg) { margin-right: 6px; margin-left: 0; }
.wc-apw-button.icon-after  i,
.wc-apw-button.icon-after  svg:not(.wc-apw-spinner-svg) { margin-left:  6px; margin-right: 0; }

.wc-apw-button.wc-apw-btn-loading {
    opacity: .7;
    pointer-events: none;
}

.wc-apw-button.wc-apw-btn-loading span { visibility: hidden; }

.wc-apw-button.wc-apw-btn-loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin-top: -9px;
    margin-left: -9px;
    border: 3px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: wc-apw-spin .7s linear infinite;
}

@keyframes wc-apw-spin {
    to { transform: rotate(360deg); }
}

/* ── Add to Cart ───────────────────────────────────────── */
.wc-apw-add-to-cart {
    background-color: #ff8844;
    color: #fff;
}

.wc-apw-add-to-cart:hover:not(:disabled) {
    background-color: #ff6622;
}

/* ── Buy Now ───────────────────────────────────────────── */
.wc-apw-buy-now {
    background-color: #0f3d3e;
    color: #fff;
}

.wc-apw-buy-now:hover:not(:disabled) {
    background-color: #0a2c2d;
}

/* ── WhatsApp ──────────────────────────────────────────── */
.wc-apw-whatsapp {
    background-color: #25d366;
    color: #fff;
}

.wc-apw-whatsapp:hover:not(:disabled) {
    background-color: #1ebe5d;
}

/* ── Call ──────────────────────────────────────────────── */
.wc-apw-call {
    background-color: #1a3a8a;
    color: #fff;
}

.wc-apw-call:hover:not(:disabled) {
    background-color: #142d6e;
}

/* ── Hover Animations ──────────────────────────────────── */
.wc-apw-button.hover-grow:hover:not(:disabled)   { transform: scale(1.04); }
.wc-apw-button.hover-shrink:hover:not(:disabled) { transform: scale(0.96); }
.wc-apw-button.hover-pulse:hover:not(:disabled)  { animation: wc-apw-pulse .5s ease-in-out; }

@keyframes wc-apw-pulse {
    0%,100% { transform: scale(1); }
    50%      { transform: scale(1.05); }
}

/* ── Auto Animations (Buy Now) ─────────────────────────── */
.wc-apw-auto-anim-pulse {
    animation: wc-apw-auto-pulse var(--wc-apw-anim-duration, 600ms) ease-in-out !important;
}
.wc-apw-auto-anim-shake {
    animation: wc-apw-shake var(--wc-apw-anim-duration, 600ms) ease-in-out !important;
}
.wc-apw-auto-anim-bounce {
    animation: wc-apw-bounce var(--wc-apw-anim-duration, 600ms) ease-in-out !important;
}
.wc-apw-auto-anim-glow {
    animation: wc-apw-glow var(--wc-apw-anim-duration, 600ms) ease-in-out !important;
}
.wc-apw-auto-anim-wave {
    animation: wc-apw-wave var(--wc-apw-anim-duration, 600ms) ease-in-out !important;
}
.wc-apw-auto-anim-heartbeat {
    animation: wc-apw-heartbeat var(--wc-apw-anim-duration, 600ms) ease-in-out !important;
}

@keyframes wc-apw-auto-pulse {
    0%,100% { transform: scale(1); }
    50%      { transform: scale(1.06); }
}
@keyframes wc-apw-shake {
    0%,100% { transform: translateX(0); }
    10%,50%,90% { transform: translateX(-5px); }
    30%,70%     { transform: translateX(5px); }
}
@keyframes wc-apw-bounce {
    0%,100% { transform: translateY(0); }
    30%      { transform: translateY(-10px); }
    60%      { transform: translateY(-4px); }
}
@keyframes wc-apw-glow {
    0%,100% { box-shadow: 0 0 0 transparent; }
    50%      { box-shadow: 0 0 18px var(--wc-apw-glow-color, rgba(255,255,255,.8)); }
}
@keyframes wc-apw-wave {
    0%  { transform: rotate(0deg); }
    25% { transform: rotate(6deg); }
    75% { transform: rotate(-6deg); }
    100%{ transform: rotate(0deg); }
}
@keyframes wc-apw-heartbeat {
    0%,100% { transform: scale(1); }
    15%     { transform: scale(1.1); }
    30%     { transform: scale(1); }
    45%     { transform: scale(1.08); }
    60%     { transform: scale(1); }
}

/* ── Toast Notification ────────────────────────────────── */
#wc-apw-toast-container {
    position: fixed;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 340px;
    width: calc(100% - 32px);
    pointer-events: none;
}

#wc-apw-toast-container[data-position="top-right"]    { top: 20px; right: 16px; align-items: flex-end; }
#wc-apw-toast-container[data-position="top-left"]     { top: 20px; left: 16px; align-items: flex-start; }
#wc-apw-toast-container[data-position="top-center"]   { top: 20px; left: 50%; transform: translateX(-50%); align-items: center; }
#wc-apw-toast-container[data-position="bottom-right"] { bottom: 20px; right: 16px; align-items: flex-end; flex-direction: column-reverse; }
#wc-apw-toast-container[data-position="bottom-left"]  { bottom: 20px; left: 16px; align-items: flex-start; flex-direction: column-reverse; }
#wc-apw-toast-container[data-position="bottom-center"]{ bottom: 20px; left: 50%; transform: translateX(-50%); align-items: center; flex-direction: column-reverse; }

.wc-apw-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    box-shadow: 0 4px 20px rgba(0,0,0,.18);
    pointer-events: all;
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity .3s, transform .3s;
    width: 100%;
    max-width: 340px;
    word-break: break-word;
    line-height: 1.4;
}

.wc-apw-toast.wc-apw-toast-show { opacity: 1; transform: translateY(0); }
.wc-apw-toast.wc-apw-toast-hide { opacity: 0; transform: translateY(-12px); }

#wc-apw-toast-container[data-position^="bottom"] .wc-apw-toast           { transform: translateY(12px); }
#wc-apw-toast-container[data-position^="bottom"] .wc-apw-toast.wc-apw-toast-show { transform: translateY(0); }
#wc-apw-toast-container[data-position^="bottom"] .wc-apw-toast.wc-apw-toast-hide { transform: translateY(12px); }

.wc-apw-toast-icon  { display: flex; flex-shrink: 0; align-items: center; }
.wc-apw-toast-text  { flex: 1; }
.wc-apw-toast-close { background: none; border: none; color: inherit; font-size: 20px; line-height: 1; cursor: pointer; opacity: .7; padding: 0 2px; margin-left: auto; flex-shrink: 0; }
.wc-apw-toast-close:hover { opacity: 1; }

/* ── Alignment ─────────────────────────────────────────── */
.wc-apw-container.align-center .wc-apw-var-options,
.wc-apw-container.align-center .wc-apw-quantity-wrapper { justify-content: center; }
.wc-apw-container.align-right  .wc-apw-var-options,
.wc-apw-container.align-right  .wc-apw-quantity-wrapper { justify-content: flex-end; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
    .wc-apw-buttons-wrapper.layout-2-column {
        grid-template-columns: 1fr 1fr;
    }
    .wc-apw-quantity-wrapper { flex-wrap: nowrap; }
    .wc-apw-button { padding: 12px 16px; font-size: 13px; letter-spacing: .2px; }
    .wc-apw-qty-button { width: 36px; height: 36px; font-size: 18px; }
    .wc-apw-qty-input  { width: 50px; height: 36px; font-size: 14px; }
    .wc-apw-var-option-btn { padding: 7px 12px; font-size: 13px; }
}

@media (max-width: 480px) {
    .wc-apw-buttons-wrapper.layout-2-column { grid-template-columns: 1fr 1fr; }
    .wc-apw-button { padding: 11px 10px; font-size: 12px; }
    .wc-apw-buttons-wrapper { gap: 8px; }
    #wc-apw-toast-container { max-width: calc(100vw - 24px); }
}

/* ── Accessibility ─────────────────────────────────────── */
.wc-apw-qty-button:focus-visible,
.wc-apw-qty-input:focus-visible,
.wc-apw-var-option-btn:focus-visible,
.wc-apw-var-image-swatch:focus-visible {
    outline: 2px solid #4caf50;
    outline-offset: 2px;
}
