/* ==========================================================================
   DELAN IMPORT TAX - CHECKOUT STYLES
   ==========================================================================

   DOM structure (CheckoutWC):

     ul.cfw-shipping-methods-list
       li
         div.cfw-shipping-method-inner
           input[type="radio"].shipping_method
           label
             span.delan-sm-label
               span.delan-sm-top
                 span.delan-sm-name
                 span.delan-sm-price
               span.delan-sm-meta
                 span.delan-sm-eta
                 span.delan-sm-badge

   All card styles are scoped to selectors containing .delan-sm-label
   so that any shipping method NOT transformed by our plugin is unaffected.
   ========================================================================== */


/* --------------------------------------------------------------------------
   0. CHECKOUTCFW - strip outer border from the ul
   The CheckoutWC theme sets border: 1px solid #ddd + border-radius: 5px
   on ul.cfw-shipping-methods-list. Our cards have their own borders so
   the outer rectangle is removed entirely.
   -------------------------------------------------------------------------- */

ul.cfw-shipping-methods-list:has(.delan-sm-label) {
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
}

/* CheckoutWC adds border-bottom + padding on every li - remove both
   since our cards have their own borders and spacing. */
ul.cfw-shipping-methods-list:has(.delan-sm-label) li {
    border-bottom: none !important;
    padding: 0 !important;
}

/* CheckoutWC theme adds margin-inline-start: .5em on the label <span>
   which pushes the whole card to the right. Reset it. */
ul.cfw-shipping-methods-list li .cfw-shipping-method-inner label span {
    margin-inline-start: 0 !important;
}


/* --------------------------------------------------------------------------
   1. LIST ITEM
   -------------------------------------------------------------------------- */

.woocommerce-shipping-methods li:has(.delan-sm-label),
.cfw-shipping-methods-list li:has(.delan-sm-label) {
    list-style: none !important;
    margin: 0 0 10px 0 !important;
    padding: 0 !important;
    position: relative;
}

.woocommerce-shipping-methods li:has(.delan-sm-label):last-child,
.cfw-shipping-methods-list li:has(.delan-sm-label):last-child {
    margin-bottom: 0 !important;
}


/* --------------------------------------------------------------------------
   2. HIDE NATIVE RADIO
   -------------------------------------------------------------------------- */

.woocommerce-shipping-methods li:has(.delan-sm-label) input[type="radio"].shipping_method,
.cfw-shipping-methods-list li:has(.delan-sm-label) input[type="radio"].shipping_method {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}


/* --------------------------------------------------------------------------
   3. LABEL + INNER WRAPPER - stretch to full width
   -------------------------------------------------------------------------- */

.woocommerce-shipping-methods label:has(.delan-sm-label),
.cfw-shipping-methods-list label:has(.delan-sm-label) {
    display: block;
    width: 100%;
    cursor: pointer;
    margin: 0 !important;
    padding: 0 !important;
}

/* .cfw-shipping-method-inner uses display:flex - without width:100% the
   label shrinks to content width instead of filling the row. */
.cfw-shipping-method-inner:has(.delan-sm-label) {
    width: 100%;
}


/* --------------------------------------------------------------------------
   4. THE CARD - span.delan-sm-label
   -------------------------------------------------------------------------- */

.delan-sm-label {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    box-sizing: border-box;

    padding: 16px 18px 16px 48px;

    border: 1.5px solid #e2e2e2;
    border-radius: 12px;
    background: #ffffff;
    cursor: pointer;
    position: relative;

    transition: border-color 0.15s ease;

    font-size: 14px;
    line-height: 1.45;
    color: #1a1a1a;
    font-weight: 400;
}


/* --------------------------------------------------------------------------
   5. CUSTOM RADIO RING + DOT
   -------------------------------------------------------------------------- */

.delan-sm-label::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid #d0d0d0;
    background: #ffffff;
    box-sizing: border-box;
    transition: border-color 0.15s ease;
}

.delan-sm-label::after {
    content: '';
    position: absolute;
    left: 21px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #1a1a1a;
    opacity: 0;
    transition: opacity 0.12s ease;
}


/* --------------------------------------------------------------------------
   6. HOVER STATE
   -------------------------------------------------------------------------- */

.woocommerce-shipping-methods label:has(.delan-sm-label):hover .delan-sm-label,
.cfw-shipping-methods-list label:has(.delan-sm-label):hover .delan-sm-label {
    border-color: #aaaaaa;
}

.woocommerce-shipping-methods label:has(.delan-sm-label):hover .delan-sm-label::before,
.cfw-shipping-methods-list label:has(.delan-sm-label):hover .delan-sm-label::before {
    border-color: #aaaaaa;
}


/* --------------------------------------------------------------------------
   7. SELECTED STATE - thick black border + filled dot
   -------------------------------------------------------------------------- */

.woocommerce-shipping-methods li.delan-selected .delan-sm-label,
.cfw-shipping-methods-list li.delan-selected .delan-sm-label,
.woocommerce-shipping-methods input[type="radio"].shipping_method:checked ~ label .delan-sm-label,
.cfw-shipping-methods-list input[type="radio"].shipping_method:checked ~ label .delan-sm-label {
    border: 2px solid #1a1a1a;
    padding: 15.5px 17.5px 15.5px 47.5px;
}

.woocommerce-shipping-methods li.delan-selected .delan-sm-label::before,
.cfw-shipping-methods-list li.delan-selected .delan-sm-label::before,
.woocommerce-shipping-methods input[type="radio"].shipping_method:checked ~ label .delan-sm-label::before,
.cfw-shipping-methods-list input[type="radio"].shipping_method:checked ~ label .delan-sm-label::before {
    border-color: #1a1a1a;
    border-width: 2px;
}

.woocommerce-shipping-methods li.delan-selected .delan-sm-label::after,
.cfw-shipping-methods-list li.delan-selected .delan-sm-label::after,
.woocommerce-shipping-methods input[type="radio"].shipping_method:checked ~ label .delan-sm-label::after,
.cfw-shipping-methods-list input[type="radio"].shipping_method:checked ~ label .delan-sm-label::after {
    opacity: 1;
}


/* --------------------------------------------------------------------------
   8. CARD INNER LAYOUT
   -------------------------------------------------------------------------- */

.delan-sm-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}

.delan-sm-name {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    flex: 1;
    letter-spacing: -0.01em;
}

.delan-sm-price {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

.delan-sm-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
    width: 100%;
    box-sizing: border-box;
}

.delan-sm-eta {
    font-size: 13px;
    color: #888888;
    flex: 1;
    font-weight: 400;
}

.delan-sm-eta strong {
    color: #555555;
    font-weight: 500;
}


/* --------------------------------------------------------------------------
   9. BADGES
   -------------------------------------------------------------------------- */

.delan-sm-badge {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 11px;
    border-radius: 20px;
    white-space: nowrap;
    line-height: 1.4;
    letter-spacing: 0.01em;
}

.delan-sm-badge--included {
    background: #e6f4dc;
    color: #386810;
}

.delan-sm-badge--not-included {
    background: #fdefd9;
    color: #894f0b;
}


/* --------------------------------------------------------------------------
   10. CHECKOUT NOTICE BOX
   -------------------------------------------------------------------------- */

.delan-shipping-note {
    display: block !important;
    width: 100% !important;
}

.delan-shipping-note th,
.delan-shipping-note td {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
    border: 0 !important;
    box-sizing: border-box;
}

.delan-shipping-box {
    width: 100%;
    box-sizing: border-box;
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #bfddc9;
    background: #f1f9f4;
    color: #1b5e3a;
    text-align: left;
    line-height: 1.5;
    font-size: 13px;
}

.delan-shipping-box__title {
    display: block;
    margin: 0 0 3px 0;
    font-weight: 600;
    font-size: 13px;
}

.delan-shipping-box__body {
    margin: 0;
    opacity: 0.85;
}

.delan-shipping-note--not-included .delan-shipping-box {
    border-color: #efd4a0;
    background: #fffbf2;
    color: #7a4f0e;
}


/* --------------------------------------------------------------------------
   11. CHECKOUT TOTALS TABLE - keep fee/tax labels on one line
   CheckoutWC renders cart/checkout totals as #cfw-cart-summary-totals >
   div.cfw-totals-list > table.cfw-module, with each fee as tr.fee (DOM
   confirmed via dev tools). The label <th> gives just enough width for
   shorter rows like "Prepaid Import Tax" but wraps longer ones like
   "Customs Clearance Fee" onto two lines. There's unused horizontal space
   next to the price column, so let the label column size to its content
   instead of wrapping.
   -------------------------------------------------------------------------- */

#cfw-cart-summary-totals table tr.fee th,
#cfw-cart-summary-totals table tr.fee td,
.woocommerce-checkout-review-order-table tr.fee th,
.woocommerce-checkout-review-order-table tr.fee td,
.woocommerce-cart-totals tr.fee th,
.woocommerce-cart-totals tr.fee td {
    white-space: nowrap;
}
