/**
 * Kusvaa Sets — Styles (v4.4)
 */

:root {
    --ks-brown:        #bd5b40;
    --ks-brown-bg:     #fff8f6;
    --ks-brown-border: #e8c5bb;
    --ks-text:         #333;
    --ks-muted:        #888;
}

/* ─── CART GROUPING ─────────────────────────────────────────── */

/* Header row — white, rounded top, full border */
tr.kusvaa-set-group-label td {
    background: #ffffff !important;
    border-top: 1px solid var(--ks-brown-border) !important;
    border-left: 1px solid var(--ks-brown-border) !important;
    border-right: 1px solid var(--ks-brown-border) !important;
    border-bottom: none !important;
    border-radius: 6px 6px 0 0 !important;
    padding: 10px 16px 6px !important;
    text-align: left !important;
    /* Collapse any spacing inherited from table */
    margin: 0 !important;
}

.kusvaa-set-badge {
    font-size: 14px;
    font-weight: 700;
    color: var(--ks-brown);
    letter-spacing: 0.01em;
    text-transform: none;
}

/* Force table to collapse spacing for set rows */
.woocommerce-cart-form table.cart {
    border-collapse: separate;
}

/* Child rows — kill ALL Flatsome card styling, apply our own */
tr.kusvaa-set-group-item td.product-thumbnail,
tr.kusvaa-set-group-item td.product-name,
tr.kusvaa-set-group-item td.product-quantity,
tr.kusvaa-set-group-item td.product-price,
tr.kusvaa-set-group-item td.product-subtotal,
tr.kusvaa-set-group-item td.product-remove {
    background: var(--ks-brown-bg) !important;
    border-top: 1px solid var(--ks-brown-border) !important;
    border-bottom: none !important;
    border-left: none !important;
    border-right: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin-bottom: 0 !important;
    margin-top: 0 !important;
}

/* Left border on thumbnail (first visible td) */
tr.kusvaa-set-group-item td.product-thumbnail {
    border-left: 1px solid var(--ks-brown-border) !important;
}

/* Right border on quantity (last visible td) */
tr.kusvaa-set-group-item td.product-quantity {
    border-right: 1px solid var(--ks-brown-border) !important;
}

/* Kill gap between rows — Flatsome uses margin-bottom on tr */
tr.kusvaa-set-group-item {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Locked qty */
.kusvaa-set-qty-locked {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Hidden individual action rows */
tr.kusvaa-set-action-row-hidden {
    display: none !important;
}

/* ─── REMOVE SET ROW ─────────────────────────────────────────── */

tr.kusvaa-set-remove-row td {
    background: #ffffff !important;
    border-top: 1px solid var(--ks-brown-border) !important;
    border-bottom: 1px solid var(--ks-brown-border) !important;
    border-left: none !important;
    border-right: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

tr.kusvaa-set-remove-row td.action-remove-item {
    border-left: 1px solid var(--ks-brown-border) !important;
    border-bottom-left-radius: 6px !important;
}

tr.kusvaa-set-remove-row td.action-move-to-wishlist {
    border-right: 1px solid var(--ks-brown-border) !important;
    border-bottom-right-radius: 6px !important;
}

/* Wishlist link */
a.kusvaa-set-wishlist-link {
    color: var(--ks-text);
    text-decoration: none;
    font-size: inherit;
    font-weight: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
}
a.kusvaa-set-wishlist-link:hover {
    color: var(--ks-brown);
}

/* ─── RETURN FORM GROUPING ──────────────────────────────────── */

tr.kusvaa-set-return-group-row {
    background: var(--ks-brown-bg);
    border-top: 1px solid var(--ks-brown-border);
}
tr.kusvaa-set-return-group-row td {
    padding: 10px 12px;
    vertical-align: middle;
}
.kusvaa-set-return-label {
    font-size: 13px;
    color: var(--ks-brown);
}
.kusvaa-set-return-note  {
    font-size: 11px;
    color: var(--ks-muted);
    font-style: italic;
}
tr.ced_rnx_return_column[data-kusvaa-set-group] {
    background: var(--ks-brown-bg);
    opacity: 0.85;
}

/* ─── ADMIN METABOX ─────────────────────────────────────────── */

.kusvaa-set-item-row {
    display: grid;
    grid-template-columns: 1fr 140px 36px;
    gap: 8px;
    align-items: center;
    background: #f8f9fa;
    border: 1px solid #dde0e3;
    border-radius: 4px;
    padding: 10px 12px;
    margin-bottom: 8px;
}
.kusvaa-set-summary table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.kusvaa-set-summary td {
    padding: 4px 6px;
    border-bottom: 1px solid #f0f0f0;
}
.kusvaa-set-summary td:first-child {
    color: #888;
    width: 90px;
}
.kusvaa-set-summary .price-ok   {
    color: #0a6;
    font-weight: 600;
}
.kusvaa-set-summary .price-warn {
    color: #a60;
    font-weight: 600;
}

/* ─── FLATSOME CUSTOM CART OVERRIDES FOR SET ROWS ────────────── */

/* Kill the 10px bottom border gap on hidden action bar rows */
tr.kusvaa-set-action-row-hidden td {
    border-bottom: none !important;
    padding: 0 !important;
    height: 0 !important;
    line-height: 0 !important;
    overflow: hidden !important;
}

/* Match Flatsome's #b4b4b4 border color for set rows */
tr.kusvaa-set-group-label td {
    border-color: #b4b4b4 !important;
}

tr.kusvaa-set-group-item td.product-thumbnail,
tr.kusvaa-set-group-item td.product-name,
tr.kusvaa-set-group-item td.product-quantity {
    border-color: #b4b4b4 !important;
    border-radius: 0 !important;
}

/* Override Flatsome's radius on thumbnail and quantity */
.woocommerce-cart-form .shop_table tbody tr.kusvaa-set-group-item td.product-thumbnail {
    border-top: 1px solid #b4b4b4 !important;
    border-left: 1px solid #b4b4b4 !important;
    border-right: none !important;
    border-bottom: none !important;
    border-radius: 0 !important;
}

.woocommerce-cart-form .shop_table tbody tr.kusvaa-set-group-item td.product-name {
    border-top: 1px solid #b4b4b4 !important;
    border-bottom: none !important;
    border-left: none !important;
    border-right: none !important;
}

.woocommerce-cart-form .shop_table tbody tr.kusvaa-set-group-item td.product-quantity {
    border-top: 1px solid #b4b4b4 !important;
    border-right: 1px solid #b4b4b4 !important;
    border-bottom: none !important;
    border-left: none !important;
    border-radius: 0 !important;
}

/* Remove row — match Flatsome bottom-action-bar style but no 10px gap */
.woocommerce-cart-form tr.kusvaa-set-remove-row td {
    border-bottom: 1px solid #b4b4b4 !important;
    border-top: 1px solid #b4b4b4 !important;
}

.woocommerce-cart-form tr.kusvaa-set-remove-row td.action-remove-item {
    border-left: 1px solid #b4b4b4 !important;
    border-bottom-left-radius: 4px !important;
    border-right: 1px solid #b4b4b4 !important;
}

.woocommerce-cart-form tr.kusvaa-set-remove-row td.action-move-to-wishlist {
    border-right: 1px solid #b4b4b4 !important;
    border-bottom-right-radius: 4px !important;
    border-left: none !important;
}
/* ============================================================================
 * KUSVAA SETS — Exchange form Section 1 grouping (Phase 6.1)
 * ========================================================================== */

tr.kusvaa-set-header-row td.kusvaa-set-header-cell {
    background: #fff;
    border: 1px solid #b4b4b4;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: 12px 8px;
    text-align: left !important;
}

tr.kusvaa-set-header-row .kusvaa-set-header-label {
    flex: 1;
    align-self: center;
    color: #b15c3a;
    font-weight: 600;
    font-size: 1em;
    line-height: 1.4;
    padding-left: 8px;
    text-align: left;
}

tr.kusvaa-set-header-row.kusvaa-set-disabled td.kusvaa-set-header-cell {
    background: #f5f5f5;
    color: #888;
}

tr.kusvaa-set-child-row > td {
    background: #fff8f6;
    border-left: 1px solid #b4b4b4;
    border-right: 1px solid #b4b4b4;
    border-bottom: 1px solid #b4b4b4;
}

/* Greyed group when set is non-returnable */
tr.kusvaa-set-header-row.kusvaa-set-disabled + tr.kusvaa-set-child-row > td,
tr.kusvaa-set-header-row.kusvaa-set-disabled ~ tr.kusvaa-set-child-row > td {
    background: #f5f5f5;
    opacity: 0.7;
}

tr.kusvaa-set-child-row label.kusvaa-hidden-set-checkbox-label {
    visibility: hidden !important;
}

tr.kusvaa-set-child-row input.kusvaa-hidden-checkbox {
    /* Hidden but functional — master triggers click */
    visibility: hidden !important;
}

/* ============================================================================
 * KUSVAA SETS — Exchange form Section 2 grouping (Phase 6.2 v3)
 * Card structure: Header (white, top-rounded) → Children (pink, with dividers) → Master action row (plugin styles, bottom-rounded)
 *
 * v3 changes vs v2:
 *  - REMOVED background:#fff !important from master action row tds — plugin's .select state (orange bg) must show through when buttons are selected
 *  - ADDED border-bottom:1px solid #b4b4b4 to child td → creates visible divider between set items (matches Section 1)
 * ========================================================================== */

/* Hide subsequent set-child action rows (only LAST child's action row visible as master) */
table.return-exchange-product tr.kusvaa-set-action-row-hidden,
table.ced_rnx_product_table tr.kusvaa-set-action-row-hidden {
    display: none !important;
}

/* Hide divider after hidden action rows (preserves gap only after master / non-set rows) */
table.return-exchange-product tr.kusvaa-set-action-row-hidden + tr.tr-divider {
    display: none;
}

/* Set child rows: pink bg, side borders + BOTTOM divider, no top/radius */
table.return-exchange-product tr.kusvaa-set-child-row > td.product-name,
table.return-exchange-product tr.kusvaa-set-child-row > td.product-quantity {
    background: #fff8f6 !important;
    border-left: 1px solid #b4b4b4 !important;
    border-right: 1px solid #b4b4b4 !important;
    border-top: none !important;
    border-bottom: 1px solid #b4b4b4 !important; /* divider line between set items */
    border-radius: 0 !important;
}

/* Master action row: side borders + bottom-rounded corners only — DO NOT override background or border-top.
   Plugin's existing styles handle: action button bg/color, .select state (orange bg + white text + checkmark),
   .disable state, hover, etc. Top border comes from last child's border-bottom (collapsed). */
table.return-exchange-product tr.kusvaa-set-action-row-master > td:first-child {
    border-left: 1px solid #b4b4b4 !important;
    border-bottom-left-radius: 6px !important;
}

table.return-exchange-product tr.kusvaa-set-action-row-master > td:last-child {
    border-right: 1px solid #b4b4b4 !important;
    border-bottom-right-radius: 6px !important;
}

/* Disabled set group: greyed visual */
table.return-exchange-product tr.kusvaa-set-header-row.kusvaa-set-disabled td.kusvaa-set-header-cell {
    background: #f5f5f5;
}

table.return-exchange-product tr.kusvaa-set-header-row.kusvaa-set-disabled .kusvaa-set-header-label {
    color: #888;
}

/* ============================================================================
 * KUSVAA SETS — Phase 6b: Cancel form
 * Cancel table mirrors exchange Section 1 by reusing plugin's .new-exchange-return-form
 * ancestor wrapper. All plugin CSS keyed on .new-exchange-return-form attaches automatically.
 * ========================================================================== */

/* Override plugin's inline <style> rule from option ced_rnx_return_custom_css:
 *   tr th.product-qty, td.product-quantity { display: none; }
 * which gets echoed inline on every plugin form template. Beat with higher specificity + !important. */
#ced_rnx_return_request_form_wrapper {
    padding: 20px;
    max-width: 850px;
    margin: 0 auto;
}
.kusvaa-cancel-modernized table.ced_rnx_product_table th.product-qty,
.kusvaa-cancel-modernized table.ced_rnx_product_table td.product-quantity {
    display: table-cell !important;
}

/* Total Refund Amount row */
.kusvaa-cancel-modernized table.ced_rnx_product_table tr.cancel-total-row th {
    text-align: left;
    padding: 12px;
    background: #f9f9f9;
    font-weight: 600;
}
.kusvaa-cancel-modernized table.ced_rnx_product_table tr.cancel-total-row td.ced_rnx_total_amount_wrap {
    text-align: right;
    padding: 12px;
    background: #f9f9f9;
    font-weight: 600;
}
.kusvaa-cancel-modernized .new-cancel-order-form .ced_rnx_cancel_product_submit{
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 999;
        width: 100%;
        margin: 0;
        height: 60px;    
}

#ced_rnx_return_request_form_wrapper .kusvaa-cancel-modernized table.ced_rnx_product_table label.container {
    border-bottom: unset;
    display: block;
    margin: auto 0;
    padding-bottom: 0;
}

.kusvaa-cancel-modernized table.ced_rnx_product_table tr.kusvaa-set-child-row td.product-name > .new-exchange-return-form > label.container {
    visibility: hidden;
}

/* ═══════════════════════════════════════════════════════════════
   Section 2 — Exchange-to Set Group display
   ════════════════════════════════════════════════════════════ */

/* Group header row */
tr.kusvaa-set-exchange-to-header td.kusvaa-set-header-cell {    
    background: #fff;
    border: 1px solid #b4b4b4;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    padding: 12px 8px;
    text-align: left !important;
}

tr.kusvaa-set-exchange-to-header .kusvaa-set-header-label {
    font-weight: 700;
    font-size: 13px;
    color: #b5451b;
}

/* Child product rows */
tr.kusvaa-set-exchange-to-child {
    background: #fff8f6;
    border-left: 2px solid #c8a96e;
    border-right: 2px solid #c8a96e;
}

tr.kusvaa-set-exchange-to-child td {
    border-bottom: 1px dashed #e8d8c4;
}

tr.kusvaa-set-exchange-to-footer {
    border-left: 2px solid #c8a96e;
    border-right: 2px solid #c8a96e;
    border-bottom: 2px solid #c8a96e;
}