/**
 * Checkout.com Custom Checkout Plugin Styles
 * Custom styles for stores using Checkout.com payment gateway
 */

/* Collapsible Shipping Address */
.woocommerce form.checkout .shipping-collapsed-view {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.woocommerce form.checkout .address-content .customer-name {
    color: #333;
    font-size: 16px;
    margin-bottom: 5px;
    display: block;
}

.woocommerce form.checkout .address-content .address-line,
.woocommerce form.checkout .address-content .phone-number {
    color: #666;
    font-size: 14px;
    display: block;
    margin-bottom: 3px;
}

.woocommerce form.checkout {
    display: grid;
    grid-template-columns: 0.9fr 1.1fr;
    grid-template-areas:
        "details review"
        "details shipping"
        "details payment"
        "details coupon"
        "return-button .";
    gap: 2rem;
}

.woocommerce form.checkout .coupon-form-section {
    grid-area: coupon;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.woocommerce form.checkout  .woocommerce-form-coupon-toggle .wc-block-components-notice-banner.is-info,
.woocommerce form.checkout  .woocommerce-form-coupon-toggle .wc-block-components-notice-banner.is-info button {
    background-color: var(--wp--preset--color--accent);
    margin: 0;
    padding: 0.75rem !important;
}

/* Make the entire coupon notice banner clickable */
.woocommerce form.checkout .woocommerce-form-coupon-toggle .wc-block-components-notice-banner__content.checkout-coupon-clickable,
.woocommerce form.checkout .woocommerce-form-coupon-toggle .wc-block-components-notice-banner__content {
    cursor: pointer;
    user-select: none;
    transition: opacity 0.2s ease;
    position: relative;
}

.woocommerce form.checkout .woocommerce-form-coupon-toggle .wc-block-components-notice-banner__content.checkout-coupon-clickable:hover,
.woocommerce form.checkout .woocommerce-form-coupon-toggle .wc-block-components-notice-banner__content:hover {
    opacity: 0.9;
}

.woocommerce form.checkout .woocommerce-form-coupon-toggle .wc-block-components-notice-banner__content.checkout-coupon-clickable:focus,
.woocommerce form.checkout .woocommerce-form-coupon-toggle .wc-block-components-notice-banner__content:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* Ensure the banner is clickable even before JS loads */
.woocommerce form.checkout .woocommerce-form-coupon-toggle .wc-block-components-notice-banner__content {
    cursor: pointer;
}

.woocommerce form.checkout  form.checkout_coupon.woocommerce-form-coupon button[type="submit"] {
    background-color: var(--wp--preset--color--accent) !important;
    color: #fff !important;
    border: none !important;
    padding: 0.75rem 2rem;
    border-radius: 0.2rem;
    min-height: auto;
}

.woocommerce form.checkout  .woocommerce-form-coupon-toggle .wc-block-components-notice-banner.is-info a:hover,
.woocommerce form.checkout  .woocommerce-form-coupon-toggle .wc-block-components-notice-banner.is-info a:visited,
.woocommerce form.checkout  .woocommerce-form-coupon-toggle .wc-block-components-notice-banner.is-info a:focus {
    text-decoration: none;
    color: #fff;
}

.woocommerce form.checkout #customer_details {
    display:flex;
    flex-direction: column;
    order: 1;
    width: 100%;
    grid-area: details;
}

.woocommerce form.checkout #order_review {
    order: 2;
    width: 100%;
    grid-area: review;
}

/* Product images in order review table */
.woocommerce form.checkout .shop_table.woocommerce-checkout-review-order-table .product-name {
    align-items: center;
    overflow: hidden;
    text-overflow: ellipsis;
}

.woocommerce form.checkout .shop_table.woocommerce-checkout-review-order-table .checkout-product-image {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    object-fit: cover;
    margin-right: 10px;
    vertical-align: middle;
    border-radius: 6px;
}

.woocommerce form.checkout .shop_table.woocommerce-checkout-review-order-table {
    width: 100%;
}

.woocommerce form.checkout .payment-methods-section {
    order: 3;
    grid-area: payment;
}

.woocommerce form.checkout #customer_details > div {
    width: 100%;
}

.woocommerce form.checkout .woocommerce-billing-fields, 
.woocommerce form.checkout .woocommerce-shipping-fields, 
.woocommerce form.checkout .woocommerce-additional-fields {
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0 2rem;
}

.woocommerce form.checkout .woocommerce-shipping-fields {
    margin-top: 2rem;
}

.woocommerce form.checkout .woocommerce-additional-fields {
    margin-top: 2rem;
}

.woocommerce form.checkout h3#order_review_heading {
    display: none;
}

.woocommerce form.checkout .checkout-com-custom-checkout-coupon-row {
    background: #f8f9fa;
    border-radius: 5px;
}

.woocommerce form.checkout .checkout-com-custom-checkout-coupon-row > div {
    padding: 15px !important;
}

/* Coupon form toggle styling */
.woocommerce form.checkout .woocommerce-form-coupon-toggle {
    margin-bottom: 0;
}

.woocommerce form.checkout .woocommerce-form-coupon-toggle .woocommerce-message {
    margin: 0;
    padding: 10px 15px;
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    border-radius: 3px;
    color: #0c5460;
}

.woocommerce form.checkout .woocommerce-form-coupon-toggle .woocommerce-message a {
    color: #007cba;
    text-decoration: none;
    font-weight: 600;
}

.woocommerce form.checkout .woocommerce-form-coupon-toggle .woocommerce-message a:hover {
    text-decoration: underline;
}

/* Coupon form styling */
.woocommerce form.checkout .checkout_coupon.woocommerce-form-coupon {
    margin: 0;
    border: none;
    padding: 0;
}

.woocommerce form.checkout .checkout_coupon .input-text {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    height: 40px;
    line-height: 1.4;
    transition: border-color 0.2s ease;
}

.woocommerce form.checkout .checkout_coupon .input-text:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 1px #007cba;
}

/* Custom shipping section */
.woocommerce form.checkout .checkout-shipping-section {
    width: 100%;
    padding: 20px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    margin: 20px 0;
}

.woocommerce form.checkout .checkout-shipping-heading {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
    color: rgb(51,51,51);
}

/* Coupon form styling */
.woocommerce form.checkout .coupon-container {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
}

/* Coupon form - always visible with proper styling from start */
.woocommerce form.checkout .coupon-form,
.woocommerce form.checkout .checkout_coupon.woocommerce-form-coupon.coupon-form {
    display: block !important;
    width: 100%;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
}

.woocommerce form.checkout .coupon-input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    width: 100%;
    min-height: 40px; /* Prevent layout shift */
}

.woocommerce form.checkout .coupon-input-wrapper {
    flex: 1;
    min-width: 0; /* Prevent flex item from overflowing */
}

.woocommerce form.checkout .coupon-input-wrapper .input-text {
    width: 100%;
    min-width: 150px;
    height: 40px;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    line-height: 1.4;
}

.woocommerce form.checkout .coupon-button-wrapper {
    flex-shrink: 0;
}

.woocommerce form.checkout .coupon-button-wrapper .button {
    height: 40px;
    padding: 10px 20px;
    min-width: 80px;
    box-sizing: border-box;
    line-height: 1.4;
    white-space: nowrap;
}

/* Return to Cart Button */
.checkout-return-to-cart {
    grid-area: return-button;
    margin-bottom: 20px;
    text-align: left;
    width: 100%;
}

.return-to-cart-btn {
    color: #6c757d;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 4px;
    display: inline-block;
    transition: all 0.3s ease;
}

.return-to-cart-btn:hover {
    background-color: #e9ecef;
    color: #495057;
    border-color: #adb5bd;
    text-decoration: none;
}

/* ============================================
   MEDIA QUERIES
   ============================================ */

/* Tablet and below */
@media (max-width: 1024px) {
    .woocommerce form.checkout #customer_details {
        width: 100%;
    }

    .woocommerce form.checkout #order_review {
        width: 100%;
        margin-top: 2rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .woocommerce form.checkout {
        grid-template-columns: 1fr;
        grid-template-areas:
            "details"
            "review"
            "payment"
            "coupon"
            "return-button";
        gap: 20px;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }
    
    /* Optional: Adjust spacing for mobile */
    form.checkout > * {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .woocommerce form.checkout .shop_table.woocommerce-checkout-review-order-table .product-name {
        white-space: unset;
    }

    .woocommerce form.checkout .shop_table.woocommerce-checkout-review-order-table td {
        min-width: auto;
    }

    .woocommerce form.checkout .checkout_coupon .input-text,
    .woocommerce form.checkout .checkout_coupon .button {
        font-size: 14px;
        padding: 10px;
    }
    
    .woocommerce form.checkout .checkout-com-custom-checkout-coupon-row > div {
        padding: 10px !important;
    }

    .woocommerce form.checkout form.checkout_coupon.woocommerce-form-coupon button[type="submit"] {
        padding: 0.9rem 2rem;
    }
    
    .woocommerce form.checkout .shipping-address-display {
        flex-direction: column;
    }

    .woocommerce form.checkout .payment-methods-section {
        margin-top: 0;
    }
    
    /* Hide product images on mobile */
    .woocommerce form.checkout .shop_table.woocommerce-checkout-review-order-table .checkout-product-image {
        display: none;
    }
    
    /* Return to cart button - full width on mobile */
    .checkout-return-to-cart {
        width: 100%;
        text-align: left;
        margin-bottom: 20px;
    }
    
    .return-to-cart-btn {
        display: block;
        width: 100%;
        text-align: left;
        box-sizing: border-box;
    }
}
