/**
 * COD Express - Form Styles
 * @package COD_Express
 */

/* CSS Variables (set by inline styles) */
.cod-express-form-wrapper {
    --ce-primary: #2563eb;
    --ce-bg: #ffffff;
    --ce-text: #1f2937;
    --ce-border: #e5e7eb;
    --ce-radius: 8px;
    --ce-btn-bg: #16a34a;
    --ce-btn-text: #ffffff;
    --ce-title-color: #1f2937;
    --ce-form-border: transparent;
}

/* Form Container */
.cod-express-form-wrapper {
    background: var(--ce-bg);
    color: var(--ce-text);
    border-radius: var(--ce-radius);
    padding: 24px;
    max-width: 500px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: 2px solid var(--ce-form-border);
}

.cod-form-header-title {
    color: var(--ce-title-color);
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 1.5rem;
}

/* Product Display */
.cod-form-product {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: #f9fafb;
    border-radius: calc(var(--ce-radius) / 2);
    margin-bottom: 20px;
}

.cod-form-product .product-image img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: calc(var(--ce-radius) / 2);
}

.cod-form-product .product-name {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
}

.cod-form-product .product-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--ce-primary);
}

/* Quantity Selector */
.cod-form-quantity {
    margin-bottom: 20px;
}

.cod-form-quantity label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

.quantity-selector {
    display: flex;
    align-items: center;
    gap: 0;
    width: fit-content;
}

.qty-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--ce-border);
    background: var(--ce-bg);
    font-size: 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.qty-btn:hover {
    background: #f3f4f6;
}

.qty-btn.minus {
    border-radius: calc(var(--ce-radius) / 2) 0 0 calc(var(--ce-radius) / 2);
}

.qty-btn.plus {
    border-radius: 0 calc(var(--ce-radius) / 2) calc(var(--ce-radius) / 2) 0;
}

.qty-input {
    width: 60px;
    height: 40px;
    border: 1px solid var(--ce-border);
    border-left: none;
    border-right: none;
    text-align: center;
    font-size: 16px;
    -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Form Fields */
.cod-form-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.cod-form-field {
    width: 100%;
}

.cod-form-field.field-width-50 {
    width: calc(50% - 8px);
}

.cod-form-field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
}

.cod-form-field .required {
    color: #ef4444;
}

.cod-form-field input,
.cod-form-field select,
.cod-form-field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--ce-border);
    border-radius: calc(var(--ce-radius) / 2);
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--ce-bg);
    color: var(--ce-text);
}

.cod-form-field input:focus,
.cod-form-field select:focus,
.cod-form-field textarea:focus {
    outline: none;
    border-color: var(--ce-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.cod-form-field textarea {
    min-height: 80px;
    resize: vertical;
}

.cod-form-field.has-error input,
.cod-form-field.has-error select,
.cod-form-field.has-error textarea {
    border-color: #ef4444;
}

.cod-form-field .field-error {
    color: #ef4444;
    font-size: 12px;
    margin-top: 4px;
}

/* Quantity Offer Box - Border Dance Animation */
.cod-quantity-offer-wrapper {
    margin: 20px 0;
}

.cod-quantity-offer {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    border-radius: 0;
    /* Sharp corners for this animation */
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    /* Border Dance Animation - BLACK */
    background:
        linear-gradient(90deg, #000 50%, transparent 50%),
        linear-gradient(90deg, #000 50%, transparent 50%),
        linear-gradient(0deg, #000 50%, transparent 50%),
        linear-gradient(0deg, #000 50%, transparent 50%),
        #fff;
    /* White background */
    background-repeat: repeat-x, repeat-x, repeat-y, repeat-y, no-repeat;
    background-size: 15px 3px, 15px 3px, 3px 15px, 3px 15px, 100% 100%;
    background-position: 0px 0px, 100% 100%, 0px 100%, 100% 0px, 0 0;
    animation: borderDance 6s infinite linear;
}

@keyframes borderDance {
    0% {
        background-position: 0px 0px, 100% 100%, 0px 100%, 100% 0px, 0 0;
    }

    100% {
        background-position: 100% 0px, 0% 100%, 0px 0%, 100% 100%, 0 0;
    }
}

.cod-quantity-offer:hover {
    transform: scale(1.01);
}

/* Green version when checked */
.cod-quantity-offer:has(.offer-checkbox:checked) {
    background:
        linear-gradient(90deg, #16a34a 50%, transparent 50%),
        linear-gradient(90deg, #16a34a 50%, transparent 50%),
        linear-gradient(0deg, #16a34a 50%, transparent 50%),
        linear-gradient(0deg, #16a34a 50%, transparent 50%),
        #f0fdf4;
    /* Light green background */
    background-repeat: repeat-x, repeat-x, repeat-y, repeat-y, no-repeat;
    background-size: 15px 3px, 15px 3px, 3px 15px, 3px 15px, 100% 100%;
    background-position: 0px 0px, 100% 100%, 0px 100%, 100% 0px, 0 0;
}

.offer-checkbox {
    width: 22px;
    height: 22px;
    margin-top: 2px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #16a34a;
}

.offer-content {
    flex: 1;
}

.offer-title {
    display: block;
    font-size: 15px;
    font-weight: 700;
    color: #1f2937;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.offer-subtitle {
    display: block;
    font-size: 13px;
    color: #6b7280;
    font-style: italic;
    text-transform: uppercase;
}

/* Button with price */
.cod-form-submit {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.cod-form-submit .button-price {
    font-size: 16px;
    font-weight: 500;
    opacity: 0.95;
}

/* Submit Button */
.cod-form-submit {
    width: 100%;
    padding: 16px 24px;
    background: var(--ce-btn-bg);
    color: var(--ce-btn-text);
    border: none;
    border-radius: var(--ce-radius);
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.cod-form-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.cod-form-submit:active {
    transform: translateY(0);
}

.cod-form-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* WhatsApp Order Button */
.cod-whatsapp-order-btn {
    width: 100%;
    padding: 14px 24px;
    background: #25D366;
    color: #fff;
    border: none;
    border-radius: var(--ce-radius, 8px);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.cod-whatsapp-order-btn:hover {
    background: #1DA851;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

.cod-whatsapp-order-btn svg {
    flex-shrink: 0;
}

.cod-form-submit.loading {
    position: relative;
    color: transparent;
}

.cod-form-submit.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top-color: var(--ce-btn-text);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Footer Badges */
.cod-form-footer {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--ce-border);
}

.cod-badge {
    font-size: 13px;
    color: #6b7280;
}

/* Popup Mode */
.cod-express-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.cod-express-popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

.cod-express-popup-content {
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    animation: popupSlideIn 0.3s ease;
}

@keyframes popupSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.cod-express-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.cod-express-popup-close:hover {
    background: #e5e7eb;
}

/* Trigger Button */
.cod-express-trigger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 10px;
    width: 100%;
}

.cod-express-trigger-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(22, 163, 74, 0.35);
}

/* Success Message */
.cod-express-success {
    text-align: center;
    padding: 40px 20px;
}

.cod-express-success .success-icon {
    width: 60px;
    height: 60px;
    background: #dcfce7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 30px;
}

.cod-express-success h3 {
    margin: 0 0 10px;
    font-size: 22px;
    color: #166534;
}

.cod-express-success p {
    margin: 0;
    color: #6b7280;
}

/* Quantity Offer Cards - Radio Style */
.cod-quantity-offers {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.quantity-offer-card {
    display: block;
    cursor: pointer;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    transition: all 0.2s ease;
}

.quantity-offer-card:hover {
    border-color: var(--ce-btn-bg, #3b82f6);
    background: #f8fafc;
}

.quantity-offer-card.offer-highlight {
    border-color: var(--ce-btn-bg, #3b82f6);
}

.quantity-offer-card input.offer-radio,
.quantity-offer-card input.variation-radio {
    display: none;
}

.quantity-offer-card input.offer-radio:checked+.offer-card-content {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-radius: 8px;
}

.quantity-offer-card input.offer-radio:checked~.offer-card-content::before,
.quantity-offer-card:has(input.variation-radio:checked)::before,
.quantity-offer-card:has(input.offer-radio:checked) {
    border-color: var(--ce-btn-bg, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.offer-card-content {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
}

.offer-card-image {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 6px;
    overflow: hidden;
    background: #f3f4f6;
}

.offer-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.offer-card-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.offer-card-title {
    font-weight: 600;
    font-size: 15px;
    color: #1f2937;
}

.offer-card-subtitle {
    font-size: 12px;
    color: #6b7280;
}

.offer-card-price {
    flex-shrink: 0;
    font-weight: 700;
    font-size: 16px;
    color: var(--ce-btn-bg, #3b82f6);
}

/* Radio indicator for cards */
.quantity-offer-card::before {
    content: '';
    position: absolute;
    left: 16px;
    /* LTR: Left */
    right: auto;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 2px solid #d1d5db;
    border-radius: 50%;
    background: #fff;
}

.quantity-offer-card {
    position: relative;
}

.quantity-offer-card:has(input.variation-radio:checked)::before,
.quantity-offer-card:has(input.offer-radio:checked)::before {
    border-color: var(--ce-btn-bg, #3b82f6);
    background: var(--ce-btn-bg, #3b82f6);
    box-shadow: inset 0 0 0 4px #fff;
}

.offer-card-content {
    display: flex;
    align-items: center;
    padding: 12px 16px 12px 48px;
    /* Left padding for radio in LTR */
    gap: 12px;
}

/* RTL support for cards */
.cod-express-form-wrapper.rtl .offer-card-content {
    /* flex-direction: row-reverse; removed to keep Image-Text-Price order */
    padding: 12px 48px 12px 16px;
    /* Right padding for radio in RTL */
}

.cod-express-form-wrapper.rtl .offer-card-text {
    text-align: right;
}

/* RTL radio position */
.cod-express-form-wrapper.rtl .quantity-offer-card::before {
    right: 16px;
    /* RTL: Right */
    left: auto;
}

/* Responsive */
@media (max-width: 480px) {
    .cod-express-form-wrapper {
        padding: 16px;
    }

    .cod-form-field.field-width-50 {
        width: 100%;
    }

    .cod-form-product {
        flex-direction: column;
        text-align: center;
    }

    .cod-form-footer {
        flex-direction: column;
        align-items: center;
    }

    .offer-card-content {
        padding: 10px 12px;
    }

    .offer-card-image {
        width: 40px;
        height: 40px;
    }
}

/* RTL Product Summary - Image on Right */
.cod-express-form-wrapper.rtl .cod-form-product {
    flex-direction: row;
    text-align: right;
    justify-content: flex-start;
}

.cod-express-form-wrapper.rtl .cod-form-product .product-image {
    order: -1;
    /* First item (Right in RTL) */
    margin-left: 16px;
    margin-right: 0;
}

.cod-express-form-wrapper.rtl .cod-form-product .product-info {
    order: 2;
}

/* Header Title Box */
.cod-form-header-title {
    border: 2px solid var(--ce-primary, #2563eb);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 700;
    font-size: 16px;
    background-color: transparent;
    color: var(--ce-text-color, #1f2937);
    line-height: 1.4;
}