.buy-now-modal,
#buy-now-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

#buy-now-modal-content {
    background: #fff;
    padding: 20px;
    max-width: 760px;
    width: 90%;
    max-height: 90vh;
    border-radius: 8px;
    position: relative;
    overflow: auto;
}

/* Close button (X) */
.buy-now-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 32px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
    z-index: 10;
}

.buy-now-modal-close:hover {
    color: #333;
}

/* Modal title */
.buy-now-modal-title {
    margin: 0 0 25px 0;
    padding-right: 40px;
    font-size: 20px;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 15px;
}

/* Continue shopping link */
.buy-now-close-link,
#buy-now-close {
    color: #0073aa;
    text-decoration: underline;
    font-weight: 400;
    transition: color 0.3s ease;
}

.buy-now-close-link:hover,
#buy-now-close:hover {
    color: #005177;
    text-decoration: underline;
}

#buy-now-checkout {
    margin-top: 0;
}

/* Checkout form notices */
#buy-now-modal .woocommerce-notices-wrapper {
    margin-bottom: 20px;
}

#buy-now-modal .woocommerce-notices-wrapper .woocommerce-error,
#buy-now-modal .woocommerce-notices-wrapper .woocommerce-message,
#buy-now-modal .woocommerce-notices-wrapper .woocommerce-info {
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 4px;
    list-style: disc;
    list-style-position: inside;
}

#buy-now-modal .woocommerce-notices-wrapper .woocommerce-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-left: 4px solid #e74c3c;
    margin-top: 30px;
}

#buy-now-modal .woocommerce-notices-wrapper .woocommerce-error li {
    margin: 5px 0;
}

#buy-now-modal .woocommerce-notices-wrapper .woocommerce-message {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #c3e6cb;
}

#buy-now-modal .woocommerce-notices-wrapper .woocommerce-info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid #bee5eb;
}

/* Field validation errors */
#buy-now-modal .woocommerce-invalid input,
#buy-now-modal .woocommerce-invalid select,
#buy-now-modal .woocommerce-invalid textarea {
    border-color: #e74c3c !important;
    background-color: #fef5f5 !important;
}

#buy-now-modal .woocommerce-invalid label {
    color: #e74c3c;
}

#buy-now-modal .form-row span.woocommerce-error {
    display: block;
    color: #e74c3c;
    font-size: 13px;
    margin-top: 5px;
    padding: 0;
    background: none;
    border: none;
}

#buy-now-modal .woocommerce-invalid-required-field abbr {
    color: #e74c3c;
    text-decoration: none;
}

/* Loading state */
#buy-now-modal .processing {
    opacity: 0.6;
    pointer-events: none;
}

#buy-now-modal .blockUI.blockOverlay {
    border-radius: 8px;
}

#buy-now-modal .woocommerce-error::before {
    display: none;
}
 #buy-now-modal .woocommerce{
    display: grid;
}
#buy-now-modal .woocommerce .checkout.woocommerce-checkout{
    order: -1;
} 
#buy-now-modal .woocommerce .col2-set {
    grid-template-columns: 1fr;
}
#buy-now-modal .woocommerce-billing-fields__field-wrapper{
    grid-template-columns: 1fr 1fr;
    display: grid;
    gap: 0 25px;
}
#buy-now-modal #billing_address_2{
    margin-top: 34px;
}

/* Hidden fields for modal checkout */
#buy-now-modal .woocommerce-form-coupon-toggle,
#buy-now-modal .woocommerce-form-login-toggle,
#buy-now-modal .rey-checkoutBar-wrapper,
#buy-now-modal .col-2,
#buy-now-modal .woocommerce-account-fields,
#buy-now-modal .buy-now-hidden-field {
    display: none !important;
}

/* Hidden Company and CUI fields for juridica */
.hidden-juridica-field,
#buy-now-modal .hidden-juridica-field,
.woocommerce-checkout .hidden-juridica-field {
    display: none !important;
}

/* Hide FGO fields by default in modal, JavaScript will show them */
#buy-now-modal #wc_order_billing_cui_fgo_client_field,
#buy-now-modal #billing_company_field {
    display: none;
}

/* Force correct field order */
.woocommerce-billing-fields__field-wrapper {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
}
.checkout-inline-error-message{
    font-size: 13px;
    line-height: 18px;
    color: #cf2929;
}
/* Set order for all fields */
#billing_first_name_field {
    order: 1;
}

#billing_last_name_field {
    order: 2;
}

#billing_person_type_field {
    order: 3;
    grid-column: 1 / 3;
}
#billing_country_field{
    order: 4;
    grid-column: 1 / 3;
}
#billing_company_field {
    order: 4;
    width: 100%;
}

#billing_cui_field {
    order: 4;
    width: 50%;
}

#billing_state_field {
    order: 6;
}

#billing_city_field {
    order: 7;
}

#billing_phone_field {
    order: 9;
    width: 50%;
}

#billing_email_field {
    order: 10;
    width: 50%;
}
#billing_address_2_field{
    margin-top: 23px;
    width: 50%;
}
#billing_address_1_field{
    width: 50%;
}
/* Hidden fields - put at the end */
#billing_postcode_field{
    grid-column: 1 / 3;
}
#billing_address_1_field,
#billing_address_2_field,
#billing_postcode_field {
    order: 100;
}
#billing_company_field .optional,
#billing_cui_field .optional{
    display: none;
}

/* Hide general error notice block - show only field-specific errors */
.woocommerce-NoticeGroup-checkout,
#buy-now-modal .woocommerce-NoticeGroup-checkout {
    display: none !important;
}

@media (max-width: 768px) {
    #buy-now-modal .woocommerce-billing-fields__field-wrapper{
        grid-template-columns: 1fr;
    }
}
#buy-now-modal  .cart-subtotal{
    display: none;
}
#buy-now-modal #billing_address_1_field,
#buy-now-modal #billing_address_2_field,
#buy-now-modal #billing_email_field,
#buy-now-modal #billing_phone_field{
    width: 100%;
}
#buy-now-modal #billing_postcode_field{
    grid-column: initial;
}