/**
 * WhatsApp WooCommerce Styles
 *
 * @package WhatsApp_WooCommerce
 * @since 1.0.0
 */

.waw-product-button-wrap,
.waw-modal,
.waw-thankyou-wrap {
    --waw-brand: #18b368;
    --waw-brand-dark: #0f8f58;
    --waw-brand-soft: #eafbf2;
    --waw-ink: #0f172a;
    --waw-muted: #475569;
    --waw-border: #d8e4ee;
    --waw-radius: 12px;
    --waw-space-scale: 1;
    --waw-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
    --waw-font: "Poppins", "Segoe UI", "Helvetica Neue", sans-serif;
}

/* Product/Loop Buttons */
.waw-product-button-wrap {
    --waw-button-spacing-scaled: calc(var(--waw-button-spacing, 12px) * var(--waw-space-scale));
    margin: var(--waw-button-spacing-scaled) 0 0;
    clear: both;
    width: 100%;
}

.waw-product-button-wrap.waw-product-button-wrap-loop {
    margin-top: var(--waw-button-spacing-scaled);
}

.waw-product-button-wrap.waw-layout-next {
    margin: 0;
    width: auto;
    clear: none;
}

.waw-product-button-wrap.waw-align-left {
    text-align: left;
}

.waw-product-button-wrap.waw-align-center {
    text-align: center;
}

.waw-product-button-wrap.waw-align-right {
    text-align: right;
}

.waw-order-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--waw-brand), var(--waw-brand-dark)) !important;
    color: #fff !important;
    border: 1px solid transparent !important;
    padding: calc(12px * var(--waw-space-scale)) calc(24px * var(--waw-space-scale)) !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
    width: auto;
    max-width: 100%;
    min-height: 46px;
    justify-content: center;
    border-radius: var(--waw-radius);
    box-shadow: 0 10px 24px rgba(15, 143, 88, 0.28);
    font-family: var(--waw-font);
}

.waw-product-button-wrap.waw-size-full .waw-order-button {
    width: 100%;
}

.waw-product-button-wrap.waw-size-default .waw-order-button {
    font-size: 15px !important;
    padding: calc(11px * var(--waw-space-scale)) calc(20px * var(--waw-space-scale)) !important;
}

.waw-product-button-wrap.waw-size-small .waw-order-button {
    font-size: 13px !important;
    padding: calc(9px * var(--waw-space-scale)) calc(13px * var(--waw-space-scale)) !important;
    min-height: 38px;
}

.waw-product-button-wrap.waw-align-left .waw-order-button {
    margin-left: 0;
    margin-right: auto;
}

.waw-product-button-wrap.waw-align-center .waw-order-button {
    margin-left: auto;
    margin-right: auto;
}

.waw-product-button-wrap.waw-align-right .waw-order-button {
    margin-left: auto;
    margin-right: 0;
}

.waw-product-button-wrap.waw-layout-next .waw-order-button {
    margin: 0;
}

.waw-product-button-wrap.waw-layout-next.waw-size-full {
    flex: 1 1 240px;
}

.waw-order-button.waw-order-button-loop,
.waw-product-button-wrap.waw-product-button-wrap-loop.waw-size-small .waw-order-button {
    padding: calc(10px * var(--waw-space-scale)) calc(14px * var(--waw-space-scale)) !important;
    font-size: 14px !important;
    min-height: 42px;
}

.waw-inline-actions {
    display: flex;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: calc(var(--waw-button-spacing, 12px) * var(--waw-space-scale));
    margin-top: calc(var(--waw-button-spacing, 12px) * var(--waw-space-scale));
}

.waw-inline-actions.waw-align-left {
    justify-content: flex-start;
}

.waw-inline-actions.waw-align-center {
    justify-content: center;
}

.waw-inline-actions.waw-align-right {
    justify-content: flex-end;
}

.waw-inline-actions > .single_add_to_cart_button,
.waw-inline-actions > .add_to_cart_button,
.waw-inline-actions > .ajax_add_to_cart,
.waw-inline-actions > .product_type_simple,
.waw-inline-actions > .product_type_variable,
.waw-inline-actions > .product_type_grouped,
.waw-inline-actions > .product_type_external {
    flex: 1 1 0;
    min-width: 0;
    width: auto !important;
    margin: 0 !important;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.waw-inline-actions > .waw-product-button-wrap {
    margin-top: 0;
    flex: 0 0 auto;
}

.waw-inline-actions > .waw-product-button-wrap.waw-size-full {
    flex: 1 1 220px;
}

.waw-inline-actions > .waw-product-button-wrap .waw-order-button {
    width: auto;
}

.waw-inline-actions > .waw-product-button-wrap.waw-size-full .waw-order-button {
    width: 100%;
}

.waw-order-button:hover {
    filter: brightness(1.03);
    transform: translateY(-1px);
}

.waw-order-button:focus {
    outline: 2px solid var(--waw-brand-dark);
    outline-offset: 2px;
}

.waw-whatsapp-icon {
    display: inline-flex;
    align-items: center;
}

.waw-whatsapp-icon svg {
    flex-shrink: 0;
}

/* Modal Overlay */
body.waw-modal-open {
    overflow: hidden;
}

.waw-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(20px * var(--waw-space-scale));
    box-sizing: border-box;
}

.waw-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 10% 20%, rgba(24, 179, 104, 0.16), transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(15, 143, 88, 0.2), transparent 42%),
        rgba(15, 23, 42, 0.6);
    cursor: pointer;
}

/* Modal Content */
.waw-modal-content {
    position: relative;
    background: #fff;
    border: 1px solid var(--waw-border);
    border-radius: calc(var(--waw-radius) + 6px);
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: calc(28px * var(--waw-space-scale));
    box-shadow: var(--waw-shadow);
    animation: waw-modal-appear 0.25s ease;
    font-family: var(--waw-font);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

@keyframes waw-modal-appear {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.waw-modal-close {
    position: absolute;
    top: calc(15px * var(--waw-space-scale));
    right: calc(15px * var(--waw-space-scale));
    background: #f8fafc;
    border: 1px solid var(--waw-border);
    border-radius: 999px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #334155;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.waw-modal-close:hover {
    background: #eef4f8;
    color: #0f172a;
    transform: scale(1.03);
}

.waw-modal-title {
    margin: 0 0 calc(6px * var(--waw-space-scale));
    font-size: 24px;
    font-weight: 700;
    color: var(--waw-ink);
    padding-right: 30px;
    letter-spacing: -0.01em;
}

.waw-modal-subtitle {
    margin: 0 0 calc(22px * var(--waw-space-scale));
    font-size: 14px;
    line-height: 1.5;
    color: var(--waw-muted);
}

/* Form Styles */
.waw-order-form {
    margin: 0;
}

.waw-form-section-title {
    margin: calc(20px * var(--waw-space-scale)) 0 calc(10px * var(--waw-space-scale));
    font-size: 13px;
    font-weight: 700;
    color: var(--waw-brand-dark);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-top: 1px solid #edf2f7;
    padding-top: calc(14px * var(--waw-space-scale));
}

.waw-order-form .waw-form-section-title:first-of-type {
    margin-top: 0;
    border-top: 0;
    padding-top: 0;
}

.waw-form-row {
    margin-bottom: calc(16px * var(--waw-space-scale));
}

.waw-form-row-half {
    display: flex;
    gap: calc(15px * var(--waw-space-scale));
}

.waw-form-row-half .waw-form-field {
    flex: 1;
}

.waw-form-field label {
    display: block;
    margin-bottom: calc(6px * var(--waw-space-scale));
    font-weight: 600;
    color: #1e293b;
    font-size: 14px;
}

.waw-form-field label .required {
    color: #e74c3c;
}

.waw-form-field input[type="text"],
.waw-form-field input[type="tel"],
.waw-form-field input[type="email"],
.waw-form-field input[type="number"],
.waw-form-field select,
.waw-form-field textarea {
    width: 100%;
    padding: calc(12px * var(--waw-space-scale)) calc(13px * var(--waw-space-scale));
    border: 1px solid var(--waw-border);
    border-radius: 10px;
    font-size: 15px;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    box-sizing: border-box;
    color: var(--waw-ink);
    font-family: var(--waw-font);
}

.waw-form-field input:hover,
.waw-form-field select:hover,
.waw-form-field textarea:hover {
    border-color: #b9c9d8;
}

.waw-form-field input:focus,
.waw-form-field select:focus,
.waw-form-field textarea:focus {
    outline: none;
    border-color: var(--waw-brand);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(24, 179, 104, 0.14);
}

.waw-form-field textarea {
    resize: vertical;
    min-height: calc(70px * var(--waw-space-scale));
}

.waw-form-field input.waw-field-error,
.waw-form-field select.waw-field-error,
.waw-form-field textarea.waw-field-error {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.12);
}

.waw-field-feedback {
    margin: calc(6px * var(--waw-space-scale)) 0 0;
    font-size: 12px;
    line-height: 1.4;
    color: #b42318;
}

/* Quantity Input */
.waw-form-field input[type="number"] {
    width: 120px;
}

/* Courier Note */
.waw-courier-note {
    background: #fffaf0;
    border: 1px solid #f6c66b;
    border-radius: calc(var(--waw-radius) - 2px);
    padding: calc(12px * var(--waw-space-scale)) calc(15px * var(--waw-space-scale));
    margin-bottom: calc(18px * var(--waw-space-scale));
}

.waw-courier-note p {
    margin: 0;
    font-size: 13px;
    color: #7a4b01;
}

/* Cart Mode Note */
.waw-cart-mode-note {
    background: #eef8ff;
    border: 1px solid #bfdcf5;
    border-radius: calc(var(--waw-radius) - 2px);
    padding: calc(11px * var(--waw-space-scale)) calc(14px * var(--waw-space-scale));
    margin-bottom: calc(16px * var(--waw-space-scale));
}

.waw-cart-mode-note p {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
    color: #1e3a5f;
    font-weight: 500;
}

/* Shipping Method */
.waw-shipping-method-note {
    margin: calc(8px * var(--waw-space-scale)) 0 0;
    font-size: 13px;
    color: var(--waw-muted);
}

/* Order Summary */
.waw-order-summary {
    background: linear-gradient(180deg, #f8fffb 0%, #f6fafc 100%);
    border: 1px solid #cce9d9;
    border-radius: var(--waw-radius);
    padding: calc(12px * var(--waw-space-scale)) calc(14px * var(--waw-space-scale));
    margin-bottom: calc(14px * var(--waw-space-scale));
}

.waw-order-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(6px * var(--waw-space-scale)) 0;
    font-size: 14px;
    color: #334155;
}

.waw-order-summary-row + .waw-order-summary-row {
    border-top: 1px dashed #dce6ef;
}

.waw-order-summary-row-total {
    color: var(--waw-ink);
    font-weight: 700;
}

/* Submit Button */
.waw-form-submit {
    margin-top: calc(25px * var(--waw-space-scale));
}

.waw-submit-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    background: linear-gradient(135deg, var(--waw-brand), var(--waw-brand-dark)) !important;
    color: #fff !important;
    border: none !important;
    padding: calc(14px * var(--waw-space-scale)) calc(24px * var(--waw-space-scale)) !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    border-radius: var(--waw-radius) !important;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
    box-shadow: 0 10px 20px rgba(15, 143, 88, 0.24);
    letter-spacing: 0.01em;
    font-family: var(--waw-font);
}

.waw-submit-button:hover {
    filter: brightness(1.03);
    transform: translateY(-1px);
}

.waw-submit-button:disabled {
    background-color: #999 !important;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading Spinner */
.waw-loading {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: waw-spin 0.8s linear infinite;
}

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

/* Form Message */
.waw-form-message {
    padding: calc(12px * var(--waw-space-scale)) calc(15px * var(--waw-space-scale));
    border-radius: calc(var(--waw-radius) - 2px);
    margin-top: calc(15px * var(--waw-space-scale));
    font-size: 14px;
    font-weight: 500;
}

.waw-form-message.success {
    background: #ecfdf3;
    border: 1px solid #b9ebce;
    color: #135533;
}

.waw-form-message.error {
    background: #fff1f2;
    border: 1px solid #fecdd3;
    color: #881337;
}

.waw-redirect-note {
    display: block;
    margin-top: 8px;
    color: #334155;
    line-height: 1.5;
}

.waw-inline-link {
    color: var(--waw-brand-dark);
    font-weight: 600;
    text-decoration: underline;
}

@media (max-width: 768px) {
    .waw-inline-actions {
        flex-direction: column;
        align-items: stretch;
        gap: calc(8px * var(--waw-space-scale));
    }

    .waw-inline-actions > .single_add_to_cart_button,
    .waw-inline-actions > .add_to_cart_button,
    .waw-inline-actions > .ajax_add_to_cart,
    .waw-inline-actions > .product_type_simple,
    .waw-inline-actions > .product_type_variable,
    .waw-inline-actions > .product_type_grouped,
    .waw-inline-actions > .product_type_external,
    .waw-inline-actions > .waw-product-button-wrap {
        flex: 1 1 100%;
        width: 100%;
    }

    .waw-product-button-wrap.waw-layout-next {
        width: 100%;
    }

    .waw-product-button-wrap.waw-layout-next .waw-order-button,
    .waw-product-button-wrap.waw-size-full .waw-order-button {
        width: 100%;
    }

    .waw-modal {
        align-items: flex-end;
        padding: 8px;
    }

    .waw-modal-content {
        max-width: none;
        width: 100%;
        max-height: calc(100dvh - 12px);
        border-radius: 18px 18px 12px 12px;
        padding: 18px 16px calc(14px + env(safe-area-inset-bottom));
    }

    .waw-modal-title {
        font-size: 21px;
    }

    .waw-modal-subtitle {
        margin-bottom: 16px;
        font-size: 13px;
    }

    .waw-form-row {
        margin-bottom: 12px;
    }

    .waw-form-row-half {
        flex-direction: column;
        gap: 0;
    }

    .waw-form-field input,
    .waw-form-field select,
    .waw-form-field textarea {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 11px 12px;
    }

    .waw-form-submit {
        position: sticky;
        bottom: -16px;
        margin: 0 -16px;
        padding: 12px 16px calc(10px + env(safe-area-inset-bottom));
        background: #fff;
        border-top: 1px solid #e5edf3;
        z-index: 2;
    }

    .waw-submit-button {
        min-height: 48px;
    }
}

/* Thank You Page Styles */
.waw-thankyou-wrap {
    background: #f8fbff;
    border: 1px solid var(--waw-border);
    border-radius: var(--waw-radius);
    padding: calc(25px * var(--waw-space-scale));
    margin: calc(25px * var(--waw-space-scale)) 0;
    text-align: center;
    font-family: var(--waw-font);
}

.waw-thankyou-wrap.waw-other-gateway {
    background: #fff9e6;
    border: 1px solid #ffc107;
}

.waw-thankyou-instructions {
    margin-bottom: 20px;
    font-size: 15px;
    color: #555;
    line-height: 1.6;
}

.waw-thankyou-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, var(--waw-brand), var(--waw-brand-dark)) !important;
    color: #fff !important;
    border: none !important;
    padding: calc(14px * var(--waw-space-scale)) calc(30px * var(--waw-space-scale)) !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    border-radius: var(--waw-radius) !important;
    text-decoration: none !important;
    transition: transform 0.15s ease, filter 0.2s ease;
}

.waw-thankyou-button:hover {
    filter: brightness(1.03);
    transform: translateY(-1px);
    color: #fff !important;
}

.waw-thankyou-button svg {
    flex-shrink: 0;
}

/* Responsive */
@media (max-width: 480px) {
    .waw-modal-title {
        font-size: 18px;
    }
}

/* Print Styles */
@media print {
    .waw-modal,
    .waw-product-button-wrap {
        display: none !important;
    }
}
