/**
 * Bookworm Theme × YITH Request a Quote — Compatibility Styles
 *
 * Purpose: Override YITH Quote default styling so every quote-related UI element
 * (buttons, tables, forms, my-account pages, mini-quote widget) follows the
 * Bookworm design system: Bootstrap 4, Inter font, #f75454 primary, square corners,
 * flat inputs, 992px breakpoint, etc.
 *
 * @version 1.0.0
 */

/* ==========================================================================
   1. CSS Custom Properties — handled dynamically by PHP
   ========================================================================== */
/* Note: The :root YITH variable overrides (--ywraq_*) are generated
   dynamically in PHP using bookworm_get_theme_colors() so they always
   match the Bookworm customizer settings. See fix-bookworm-yith-quote.php. */

/* ==========================================================================
   2. Add-to-Quote Button — Single Product & Loop
   ========================================================================== */

/* Override YITH's oversized padding + !important to match Bookworm .btn style */
.woocommerce ul.products li.product a.add-request-quote-button.button,
.wp-block-post.product a.add-request-quote-button.button,
a.add-request-quote-button.button,
.yith-ywraq-add-to-quote .add-request-quote-button {
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .875rem !important;
    font-weight: 500;
    padding: .75rem 1.2rem !important;
    margin-top: .5rem;
    border-radius: 0 !important;
    text-transform: none;
    letter-spacing: normal;
    line-height: 1.5;
    transition: color .3s ease-in-out,
                background-color .3s ease-in-out,
                border-color .3s ease-in-out;
}

/* Ensure button colors follow Bookworm variables even over YITH's !important */
.woocommerce .add-request-quote-button.button,
.woocommerce .add-request-quote-button-addons.button {
    background-color: var(--ywraq_layout_button_bg_color, #f75454) !important;
    color: var(--ywraq_layout_button_color, #fff) !important;
    border: 1px solid var(--ywraq_layout_button_border_color, #f75454) !important;
}

.woocommerce .add-request-quote-button.button:hover,
.woocommerce .add-request-quote-button-addons.button:hover {
    background-color: var(--ywraq_layout_button_bg_color_hover, #e64848) !important;
    color: var(--ywraq_layout_button_color_hover, #fff) !important;
    border: 1px solid var(--ywraq_layout_button_border_color_hover, #e64848) !important;
}

/* Disabled state — gentler than YITH's heavy-handed opacity */
.add-request-quote-button.disabled {
    opacity: .65 !important;
    cursor: not-allowed;
    pointer-events: none;
}

/* "Already in quote" / "Browse list" message styling */
.yith-ywraq-add-to-quote .yith_ywraq_add_item_response_message,
.yith-ywraq-add-to-quote .yith_ywraq_add_item_browse_message {
    font-size: .875rem;
    color: #161619;
    margin-top: .35rem;
}

.yith-ywraq-add-to-quote .yith_ywraq_add_item_browse_message a {
    color: var(--primary, #f75454);
    text-decoration: underline;
    font-weight: 500;
}

.yith-ywraq-add-to-quote .yith_ywraq_add_item_browse_message a:hover {
    color: #e64848;
}

/* Icon (when plugin uses icon mode instead of text label) */
.ywraq-quote-icon-icon_quote:before {
    font-size: 20px;
    color: inherit;
}

/* ==========================================================================
   3. Quote Page — Table
   ========================================================================== */

/* Align table padding/spacing to Bookworm's WooCommerce tables */
#yith-ywraq-form table.shop_table.cart {
    border-radius: 0;
    border-collapse: collapse;
    border: 1px solid #dee2e6;
    margin-bottom: 1.5rem;
}

#yith-ywraq-form table.shop_table.cart thead th {
    background-color: #f8f9fa;
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .875rem;
    font-weight: 600;
    color: #161619;
    padding: 1rem 1.2rem;
    border-bottom: 2px solid #dee2e6;
    text-transform: none;
}

#yith-ywraq-form .product-subtotal,
#yith-ywraq-form .product-quantity,
#yith-ywraq-form .product-price {
    text-align: right;
    padding: 1rem 1.2rem;
}

#yith-ywraq-form table.shop_table.cart tbody tr td {
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .875rem;
    padding: 1rem 1.2rem;
    vertical-align: middle;
    border-top: 1px solid #dee2e6;
}

/* Product thumbnail — consistent sizing */
.woocommerce #yith-ywraq-form table.shop_table.cart div.product-thumbnail img {
    max-width: 80px;
    height: auto;
    border-radius: 0;
}

/* Remove link */
.product-remove a.yith-ywraq-item-remove.remove {
    color: #999;
    font-size: 1.5rem;
    text-decoration: none;
}

.product-remove a.yith-ywraq-item-remove.remove:hover {
    color: #f75454;
    background: none;
}

/* Totals row */
.raq-totals {
    text-align: right;
    padding: 1rem 1.2rem !important;
    font-weight: 600;
}

/* After-table buttons (update, clear, PDF) */
#yith-ywraq-form .update-list-wrapper {
    margin-bottom: 1.5rem;
}

#yith-ywraq-form .update-list-wrapper .button,
button.ywraq_clean_list,
button#ywraq-list-to-pdf {
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .875rem;
    font-weight: 500;
    padding: .75rem 1.2rem;
    border-radius: 0;
    text-transform: none;
    line-height: 1.5;
    transition: all .3s ease-in-out;
}

/* Update List button — follow Bookworm primary button style
   EN: Match Bookworm .btn-primary appearance for the Update List submit button.
   ZH: 讓 Update List 按鈕跟隨 Bookworm 主色按鈕風格。 */
#yith-ywraq-form .update-list-wrapper > input[type="submit"][name="update_raq"],
#yith-ywraq-form .update-list-wrapper > input[type="submit"].button {
    background-color: var(--primary, #f75454) !important;
    color: var(--ywraq_layout_button_color, #fff) !important;
    border: 1px solid var(--primary, #f75454) !important;
    border-radius: 0;
    cursor: pointer;
}
#yith-ywraq-form .update-list-wrapper > input[type="submit"][name="update_raq"]:hover,
#yith-ywraq-form .update-list-wrapper > input[type="submit"].button:hover {
    opacity: .85;
}

button#ywraq-list-to-pdf {
    background: #f8f9fa;
    border-color: #dee2e6;
    color: #161619;
}

button#ywraq-list-to-pdf:hover {
    background: #e9ecef;
}

/* Return to shop button */
a.button.return_to_shop_url {
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .875rem;
    padding: .75rem 1.2rem;
    border-radius: 0;
}

/* ==========================================================================
   4. Quote Page — Default Form (popup & inline)
   ========================================================================== */

/* Form wrapper */
.yith-ywraq-mail-form-wrapper {
    font-family: "Inter", Helvetica, Arial, sans-serif;
    padding: 1.5rem;
    background-color: #f8f9fa;
    border-radius: 0;
}

/* Input / Textarea */
.yith-ywraq-mail-form-wrapper input[type="text"],
.yith-ywraq-mail-form-wrapper input[type="email"],
.yith-ywraq-mail-form-wrapper input[type="tel"],
.yith-ywraq-mail-form-wrapper input[type="number"],
.yith-ywraq-mail-form-wrapper input[type="password"],
.yith-ywraq-mail-form-wrapper textarea,
.yith-ywraq-mail-form-wrapper select {
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .875rem;
    font-weight: 400;
    color: #161619;
    background-color: #fff;
    border: 1px solid #dfdcd7;
    border-radius: 0;
    padding: .844rem 1rem;
    height: auto;
    line-height: 1.5;
    transition: border-color .3s ease-in-out;
    width: 100%;
    box-sizing: border-box;
}

.yith-ywraq-mail-form-wrapper input:focus,
.yith-ywraq-mail-form-wrapper textarea:focus,
.yith-ywraq-mail-form-wrapper select:focus {
    border-color: #161619;
    outline: none;
    box-shadow: none;
}

/* Override YITH's harsh placeholder color */
.yith-ywraq-mail-form-wrapper input::placeholder,
.yith-ywraq-mail-form-wrapper textarea::placeholder {
    color: #7c6e65 !important;
    font-size: .875rem !important;
    opacity: 1;
}

/* Form labels */
.yith-ywraq-mail-form-wrapper label {
    font-size: .875rem;
    font-weight: 500;
    color: #161619;
    margin-bottom: .35rem;
    display: inline-block;
}

/* Submit button */
.yith-ywraq-mail-form-wrapper input[type="submit"],
.yith-ywraq-mail-form-wrapper button[type="submit"],
#yith-ywraq-default-form .button {
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .875rem;
    font-weight: 500;
    padding: .75rem 1.2rem;
    background-color: var(--primary, #f75454);
    color: #fff;
    border: 1px solid var(--primary, #f75454);
    border-radius: 0;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
    transition: all .3s ease-in-out;
}

.yith-ywraq-mail-form-wrapper input[type="submit"]:hover,
.yith-ywraq-mail-form-wrapper button[type="submit"]:hover,
#yith-ywraq-default-form .button:hover {
    background-color: #e64848;
    border-color: #e64848;
    color: #fff;
}

/* ==========================================================================
   5. Checkout Button
   ========================================================================== */

#ywraq_cart_quote.button,
#ywraq_checkout_quote_button.button {
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .875rem;
    font-weight: 500;
    padding: .75rem 1.2rem;
    border-radius: 0;
    text-transform: none;
    width: 100%;
    line-height: 1.5;
}

/* ==========================================================================
   6. My Account — Quote List
   ========================================================================== */

/* Title */
h2.ywraq_my_account_quotes_title {
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: #161619;
    margin-bottom: 1rem;
}

/* Table */
table.shop_table.my_account_quotes.my_account_orders {
    font-size: .875rem;
    margin-top: 1rem;
    border-collapse: collapse;
    border-radius: 0;
    border: 1px solid #dee2e6;
}

table.my_account_quotes thead th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #161619;
    padding: 1rem 1.2rem;
    border-bottom: 2px solid #dee2e6;
}

table.my_account_quotes tbody tr td {
    padding: .85rem 1.2rem;
    border-top: 1px solid #dee2e6;
    vertical-align: middle;
}

table.my_account_quotes tr.quotes:hover {
    background: #f8f9fa;
}

/* Quote number link */
td.quotes-number a {
    color: var(--primary, #f75454);
    font-weight: 600;
    text-decoration: none;
}

td.quotes-number a:hover {
    text-decoration: underline;
}

/* Status badges — remap to Bookworm-friendly palette */
.raq_status {
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .6875rem;
    font-weight: 600;
    padding: .25rem .6rem;
    border-radius: .15rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    display: inline-block;
    text-align: center;
    min-width: auto;
    line-height: 1.4;
}

.raq_status.new {
    background: #fff3cd;
    color: #856404;
}

.raq_status.on-hold,
.raq_status.pending {
    background: #fff3cd;
    color: #856404;
}

.raq_status.processing {
    background: #d4edda;
    color: #155724;
}

.raq_status.accepted,
.raq_status.completed {
    background: #d4edda;
    color: #155724;
}

.raq_status.failed {
    background: #f8d7da;
    color: #721c24;
}

.raq_status.expired,
.raq_status.trash {
    background: #f8d7da;
    color: #721c24;
}

/* Accept button in list */
.quotes-total a.button.accept {
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .6875rem;
    font-weight: 500;
    padding: .3rem .6rem;
    border: 1px solid #88cf00;
    background: none;
    color: #88cf00;
    border-radius: .15rem;
    text-transform: uppercase;
}

.quotes-total a.button.accept:hover {
    background: #88cf00;
    color: #fff;
}

/* Actions menu (More button) */
.quote-actions__more {
    height: 32px;
    width: 32px;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
    opacity: 0;
    transition: opacity .3s;
}

.quotes:hover .quote-actions__more {
    opacity: 1;
}

.quote-actions-button__menu {
    border-radius: .15rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
    background: #fff;
    z-index: 100;
}

.quote-actions-button__menu__item {
    font-size: .8125rem;
    padding: .5rem 1rem;
    color: #161619;
    text-decoration: none;
}

.quote-actions-button__menu__item:hover {
    background: #f8f9fa;
    color: var(--primary, #f75454);
}

/* ==========================================================================
   7. My Account — View Single Quote
   ========================================================================== */

/* Order details table */
.ywraq-view-quote-wrapper table.shop_table.order_details {
    background-color: #fff;
    padding: 0;
    border: 1px solid #dee2e6;
    border-radius: 0;
    margin-bottom: 2rem;
}

.ywraq-view-quote-wrapper table.shop_table.order_details tbody tr td,
.ywraq-view-quote-wrapper table.shop_table tfoot tr td {
    border: 0;
    border-top: 1px solid #dee2e6;
    padding: .85rem 1.2rem;
    font-size: .875rem;
}

.woocommerce-account .woocommerce-MyAccount-content .ywraq-view-quote-wrapper .order_details th,
.woocommerce-account .woocommerce-MyAccount-content .ywraq-view-quote-wrapper .order_details thead th {
    padding: 1rem 1.2rem;
    font-size: .875rem;
    font-weight: 600;
    background-color: #f8f9fa;
}

.woocommerce-account .woocommerce-MyAccount-content .ywraq-view-quote-wrapper .order_details tfoot th {
    border: 0;
    border-top: 1px solid #dee2e6;
    padding: .85rem 1.2rem;
}

.ywraq-view-quote-wrapper table.shop_table.order_details .product-thumbnail img {
    max-width: 80px;
    height: auto;
}

/* Status text in view-quote */
.ywraq-status.pending,
.ywraq-status.on-hold,
.ywraq-status.ywraq-pending {
    color: #856404;
}

.ywraq-status.processing,
.ywraq-status.ywraq-new {
    color: #856404;
}

.ywraq-status.completed {
    color: #155724;
}

.ywraq-status.ywraq-rejected,
.ywraq-status.ywraq-expired,
.ywraq-status.trash,
.ywraq-status.failed {
    color: #721c24;
}

/* Accept/Reject big buttons */
a.ywraq-big-button {
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .875rem;
    font-weight: 500;
    border-radius: 0;
    padding: .75rem 1.5rem;
    text-transform: none;
    transition: all .3s ease-in-out;
}

a.ywraq-big-button.ywraq-accept {
    padding: .75rem 1.5rem;
    background: #88cf00;
    color: #fff;
    border-color: #88cf00;
}

a.ywraq-big-button.ywraq-accept:hover {
    background: #7abb00;
    border-color: #7abb00;
}

a.ywraq-big-button.ywraq-reject {
    padding: .75rem 1.5rem;
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
    margin-left: .5rem;
}

a.ywraq-big-button.ywraq-reject:hover {
    background: #c82333;
    border-color: #c82333;
}

a.ywraq-big-button.ywraq-pdf-file {
    background: #f8f9fa;
    color: #161619;
    border-color: #dee2e6;
    border-radius: 0;
}

/* Buttons wrapper in view-quote */
.ywraq-buttons a.ywraq-button.ywraq-accept,
.ywraq-buttons a.ywraq-button.ywraq-reject {
    border-radius: 0;
    text-transform: none;
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .875rem;
    font-weight: 500;
}

/* Additional information section */
.ywraq-additional-information > div {
    border-radius: 0;
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .875rem;
}

.ywraq-customer-information {
    border: 1px solid #dee2e6;
    border-radius: 0;
}

.ywraq-admin-message {
    box-shadow: 0 1px 6px rgba(0, 0, 0, .08);
    border-radius: 0;
}

/* Reject confirmation dialog — reset jQuery UI dialog */
#ywraq-reject-confirm textarea {
    border-radius: 0;
    border-color: #dfdcd7;
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .875rem;
}

#ywraq-reject-confirm button.button {
    border-radius: 0;
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .875rem;
    text-transform: none;
}

/* ==========================================================================
   8. Mini Quote List Widget
   ========================================================================== */

.widget_ywraq_mini_list_quote .yith-ywraq-list-content {
    background: #fff;
    border-radius: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .875rem;
}

.widget_ywraq_mini_list_quote .raq-info {
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .875rem;
    border-color: #dee2e6;
}

ul.yith-ywraq-list li a {
    font-weight: 600;
    color: #161619;
}

ul.yith-ywraq-list li a:hover {
    color: var(--primary, #f75454);
}

/* ==========================================================================
   9. jQuery UI Dialog Override (used by YITH for form popups)
   ========================================================================== */

.ui-dialog.ywraq-reject-confirm,
.ui-dialog {
    font-family: "Inter", Helvetica, Arial, sans-serif;
    border-radius: 0;
}

.ui-dialog .ui-dialog-titlebar {
    border-radius: 0;
    font-family: "Inter", Helvetica, Arial, sans-serif;
}

.ui-dialog .ui-dialog-content {
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .875rem;
}

/* ==========================================================================
   10. Responsive — Fix breakpoints from YITH's 1024px to Bookworm's 992px
   ========================================================================== */

/* Override YITH's 1024px grid breakpoint for the wide form layout */
@media screen and (min-width: 992px) {
    .ywraq-with-form .ywraq-form-table-wrapper.wide {
        display: grid;
        overflow: hidden;
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 1fr;
        grid-column-gap: 1.5rem;
        grid-row-gap: .5rem;
    }
}

/* Undo YITH's own 1024px rule to avoid double-stacking */
@media screen and (min-width: 993px) and (max-width: 1024px) {
    .yith-ywraq-mail-form-wrapper {
        margin-top: 0;
    }
}

/* Tablet override (max 768px already handled by YITH; 769-992 is the gap) */
@media screen and (max-width: 992px) {
    .ywraq-additional-information {
        flex-direction: column;
    }

    .ywraq-additional-information > div {
        width: 100%;
        margin-right: 0;
        margin-bottom: 1rem;
    }

    .ywraq-customer-information {
        margin-right: 0;
    }
}

/* Small mobile tweaks */
@media screen and (max-width: 768px) {
    .ywraq_responsive .product-name {
        font-weight: 600;
        font-size: .8125rem;
    }

    .ywraq_responsive .product-name span {
        font-weight: 400;
        color: #7c6e65;
        font-size: .8125rem;
    }

    table.shop_table.ywraq_responsive .product-remove {
        max-width: 30px;
        padding: .5rem;
    }

    /* My account quote table on mobile */
    table.my_account_quotes tbody tr td {
        padding: .6rem .8rem;
        font-size: .8125rem;
    }

    /* Accept/reject big buttons stack on mobile */
    a.ywraq-big-button.ywraq-reject {
        margin-left: 0;
        margin-top: .5rem;
    }
}

/* ==========================================================================
   11. Cart Page — "Request a Quote" button on cart
   ========================================================================== */

#ywraq-request-a-quote-on-cart p.form-row.form-row-wide.raq-send-request-row input {
    font-family: "Inter", Helvetica, Arial, sans-serif;
    font-size: .875rem;
    font-weight: 500;
    padding: .75rem 1.2rem;
    border-radius: 0;
    text-transform: none;
}

/* ==========================================================================
   12. Loop (Shop / Archive) — Quote button below product
   ========================================================================== */

.woocommerce ul.products li.product a.add-request-quote-button.button {
    margin-top: .5rem;
    display: inline-block;
}

/* When add-to-cart is hidden, make quote button full width */
.woocommerce ul.products li.product .yith-ywraq-add-to-quote {
    width: 100%;
}

/* ==========================================================================
   13. reCAPTCHA spacing
   ========================================================================== */

.g-recaptcha {
    margin-bottom: 1rem;
}

/* ==========================================================================
   14. Proteo theme references neutralizer
   Override any .theme-yith-proteo selectors that might accidentally match
   ========================================================================== */

.theme-yith-proteo .ywraq-view-quote-wrapper table.shop_table tbody tr td.product-name a,
.ywraq-view-quote-wrapper table.shop_table tbody tr td.product-name a {
    color: var(--primary, #f75454);
}

.theme-yith-proteo .quotes-total a.button.accept,
.quotes-total a.button.accept {
    border-color: var(--ywraq_accept_button_border_color, #161619);
    color: var(--ywraq_accept_button_color, #fff);
    background-color: var(--ywraq_accept_button_bg_color, #161619);
}
