/**
 * Valolma Special Products - Styles
 * v2.5.0 — Uses Kadence template #191 for special products page
 *
 * Uses Kadence --global-palette CSS variables.
 */

/* ============================================
   Validation
   ============================================ */

/* ============================================
   Error messages
   ============================================ */
.vsp-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 1rem 1.25rem;
    border-radius: var(--global-border-radius, 4px);
    margin-bottom: 1.5rem;
    font-size: var(--global-body-font-size, 1rem);
    font-family: var(--global-body-font-family, inherit);
}

/* ============================================
   Tabs Navigation — colored pill buttons
   ============================================ */
.vsp-tabs-row {
    padding-top: var(--global-kb-spacing-sm, 1.5rem);
}

.vsp-tabs-nav {
    display: flex;
    gap: 2px;
    margin-bottom: 0;
    flex-wrap: wrap;
}

.vsp-tab-btn {
    background: var(--global-palette-btn-bg, var(--global-palette1, #e67e22));
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: var(--global-body-font-size, 0.9375rem);
    font-family: var(--global-body-font-family, inherit);
    font-weight: 600;
    color: var(--global-palette-btn, var(--global-palette9, #fff));
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    opacity: 0.55;
}

.vsp-tab-btn:first-child {
    border-radius: var(--global-border-radius, 4px) 0 0 var(--global-border-radius, 4px);
}

.vsp-tab-btn:last-child {
    border-radius: 0 var(--global-border-radius, 4px) var(--global-border-radius, 4px) 0;
}

.vsp-tab-btn:only-child {
    border-radius: var(--global-border-radius, 4px);
}

.vsp-tab-btn:hover {
    opacity: 0.85;
}

.vsp-tab-btn.vsp-tab-active {
    opacity: 1;
}

.vsp-tab-btn.vsp-tab-completed {
    opacity: 0.7;
    background: #059669;
}

.vsp-tab-btn.vsp-tab-completed .vsp-tab-done-icon {
    display: inline !important;
    font-weight: 700;
}

/* ============================================
   Product Panel — use visibility instead of display:none
   so Splide/Kadence gallery can initialize properly
   ============================================ */
.vsp-product-panel {
    position: absolute;
    visibility: hidden;
    pointer-events: none;
    height: 0;
    overflow: hidden;
    opacity: 0;
}

.vsp-product-panel.vsp-panel-active {
    position: static;
    visibility: visible;
    pointer-events: auto;
    height: auto;
    overflow: visible;
    opacity: 1;
}

/* ============================================
   Kadence Template Content — inside panels
   ============================================ */
.vsp-template-content {
    /* Let Kadence's own styles handle the layout */
}

/* Hide the native WooCommerce variation selector and "Valitse vaihtoehdoista" button
   since variant is pre-selected by tab */
.vsp-special-products .variations,
.vsp-special-products .kwt-add-to-cart-wrap .variations_form > .single_variation_wrap > .woocommerce-variation,
.vsp-special-products .kwt-add-to-cart-wrap .woocommerce-variation-add-to-cart {
    display: none !important;
}

/* Hide the "Valitse vaihtoehdoista" text that appears when no variant is selected in native WC */
.vsp-special-products .woocommerce-variation-add-to-cart--disabled {
    display: none !important;
}

/* ============================================
   Inline Add-to-Cart (inside template block position)
   ============================================ */
.vsp-inline-add-to-cart {
    margin-top: 0.5rem;
}

/* ============================================
   Measurement Form — Floating label style (shared)
   ============================================ */
.vsp-measurement-form {
    margin-bottom: 1rem;
}

.vsp-float-field {
    margin-bottom: 1rem;
}

.vsp-float-input-wrap {
    position: relative;
    border: 1px solid var(--global-palette7, #d1d5db);
    border-radius: var(--global-border-radius, 4px);
    background: var(--global-palette9, #fff);
    transition: border-color 0.2s;
}

.vsp-float-input-wrap:focus-within {
    border-color: var(--global-palette3, #111827);
}

.vsp-float-input-wrap.vsp-input-error {
    border-color: #ef4444;
}

.vsp-float-input {
    display: block;
    width: 100% !important;
    border: none !important;
    background: transparent !important;
    padding: 1.25rem 0.875rem 0.5rem !important;
    font-size: var(--global-body-font-size, 1rem);
    font-family: var(--global-body-font-family, inherit);
    color: var(--global-palette3, #111827);
    outline: none;
    -moz-appearance: textfield;
    box-sizing: border-box;
}

.vsp-float-input::-webkit-outer-spin-button,
.vsp-float-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.vsp-float-label {
    position: absolute;
    top: 50%;
    left: 0.875rem;
    transform: translateY(-50%);
    font-size: var(--global-body-font-size, 1rem);
    font-family: var(--global-body-font-family, inherit);
    color: var(--global-palette5, #6b7280);
    pointer-events: none;
    transition: all 0.15s ease;
    background: transparent;
    padding: 0;
    white-space: nowrap;
}

.vsp-float-input:focus + .vsp-float-label,
.vsp-float-input:not(:placeholder-shown) + .vsp-float-label {
    top: 0.375rem;
    transform: translateY(0);
    font-size: 0.75rem;
    color: var(--global-palette5, #6b7280);
}

.vsp-field-helper {
    font-size: 0.8125rem;
    color: var(--global-palette5, #6b7280);
    font-family: var(--global-body-font-family, inherit);
    line-height: 1.4;
    margin: 0.375rem 0 0;
}

.vsp-validation-msg {
    display: block;
    font-size: 0.8125rem;
    color: #ef4444;
    margin-bottom: 0.25rem;
    font-family: var(--global-body-font-family, inherit);
}

.vsp-validation-msg:empty {
    display: none;
}

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

.vsp-input {
    -moz-appearance: textfield;
}

/* ============================================
   Price display
   ============================================ */
.vsp-single-price-display {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.vsp-single-price-display .vsp-calculated-price,
.vsp-calculated-price {
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--global-palette3, #111827);
    font-family: var(--global-body-font-family, inherit);
}

/* ============================================
   Add to Cart Button
   ============================================ */
.vsp-add-to-cart-wrap {
    margin-top: 1.25rem;
}

.vsp-add-to-cart-btn {
    display: block;
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: var(--global-palette-btn-bg, var(--global-palette1, #e67e22));
    color: var(--global-palette-btn, var(--global-palette9, #fff));
    border: none;
    border-radius: var(--global-border-radius, 4px);
    font-size: 1rem;
    font-family: var(--global-body-font-family, inherit);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, opacity 0.2s;
    text-align: center;
    text-transform: none;
    letter-spacing: 0.02em;
    line-height: 1.6;
}

.vsp-add-to-cart-btn:hover:not(:disabled) {
    background: var(--global-palette-btn-bg-hover, var(--global-palette2, #d35400));
    color: var(--global-palette-btn-hover, var(--global-palette9, #fff));
}

.vsp-add-to-cart-btn:active:not(:disabled) {
    transform: scale(0.99);
}

.vsp-add-to-cart-btn:disabled,
.vsp-add-to-cart-btn.vsp-btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.vsp-add-to-cart-btn.vsp-loading {
    position: relative;
    color: transparent;
}

.vsp-add-to-cart-btn.vsp-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: vsp-spin 0.6s linear infinite;
}

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

/* ============================================
   Success Messages
   ============================================ */
.vsp-tab-success {
    margin-top: 0.75rem;
}

.vsp-success-msg {
    color: #059669;
    font-weight: 600;
    font-size: var(--global-body-font-size, 0.9375rem);
    font-family: var(--global-body-font-family, inherit);
}

.vsp-all-done {
    text-align: center;
    padding: 3rem 1rem;
}

.vsp-all-done-inner {
    max-width: 400px;
    margin: 0 auto;
}

.vsp-all-done-msg {
    font-size: var(--global-h3-font-size, 1.25rem);
    font-weight: 600;
    color: #059669;
    margin-bottom: 1.5rem;
    font-family: var(--global-heading-font-family, var(--global-body-font-family, inherit));
}

.vsp-go-to-cart-btn {
    display: inline-block;
    padding: 0.875rem 2.5rem;
    background: var(--global-palette-btn-bg, var(--global-palette1, #e67e22));
    color: var(--global-palette-btn, var(--global-palette9, #fff)) !important;
    border: none;
    border-radius: var(--global-border-radius, 4px);
    font-size: 1rem;
    font-family: var(--global-body-font-family, inherit);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none !important;
    transition: background 0.2s;
}

.vsp-go-to-cart-btn:hover {
    background: var(--global-palette-btn-bg-hover, var(--global-palette2, #d35400));
}

/* ============================================
   Single Product Page — WC integration
   ============================================ */
.vsp-hidden-qty {
    display: none !important;
}

#vsp-single-product-form {
    margin-bottom: 1rem;
}

/* Disable WC native add-to-cart when validation fails */
.single_add_to_cart_button.vsp-btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .vsp-tabs-nav {
        flex-direction: column;
        gap: 4px;
    }

    .vsp-tab-btn {
        border-radius: var(--global-border-radius, 4px) !important;
    }


    /* Gallery full-width on mobile */
    .kwt-gallery-wrap .product_image {
        max-width: 100% !important;
    }

    .kwt-gallery-wrap .product_image img {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
    }

    /* Remove extra gallery padding on mobile */
    .ksk-gallery {
        padding: 0;
    }
}

/* ============================================
   Debug Panel
   ============================================ */
.vsp-debug-panel {
    overflow-x: auto;
}

.vsp-debug-panel table {
    min-width: 100%;
}

/* ============================================
   Variant Selector (v2.7.0)
   ============================================ */
.vsp-variant-selector {
    margin-bottom: 1.25rem;
}

.vsp-variant-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--global-palette4, #374151);
    font-family: var(--global-body-font-family, inherit);
    margin-bottom: 0.5rem;
}

.vsp-variant-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.vsp-variant-btn {
    padding: 0.5rem 1rem;
    border: 2px solid var(--global-palette7, #d1d5db);
    border-radius: var(--global-border-radius, 4px);
    background: var(--global-palette9, #fff);
    color: var(--global-palette4, #374151);
    font-size: 0.875rem;
    font-family: var(--global-body-font-family, inherit);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.vsp-variant-btn:hover {
    border-color: var(--global-palette3, #111827);
    color: var(--global-palette3, #111827);
}

.vsp-variant-btn.vsp-variant-active {
    border-color: var(--global-palette1, #e67e22);
    background: var(--global-palette1, #e67e22);
    color: var(--global-palette9, #fff);
}
