/* =====================================================================
   KD Side Cart — Koningdrone
   Section names match the Elementor Navigator names in BUILD-MAP.md:
   KD Cart · 01 Header   .kd-cart-header
   KD Cart · 02 Items    .kd-cart-items     (rows: .kd-ci.kd-cart-item)
   KD Cart · 03 Gift     .kd-ci.kd-cart-gift
   KD Cart · 04 Upsell   .kd-cart-upsell    (cards: .kd-up)
   KD Cart · 05 Footer   .kd-cart-footer    (.kd-cart-trust / -subtotal / .kd-checkout / -payments)
   ===================================================================== */
:root {
    --kd-brand: #1a4fd6;
    --kd-brand-dk: #1340b4;
    --kd-brand-lt: #e9efff;
    --kd-ink: #0c1627;
    --kd-ink-2: #39465c;
    --kd-muted: #5a6780;
    --kd-line: #e2e7f0;
    --kd-canvas: #f4f7fc;
    --kd-surface: #ffffff;
    --kd-night: #070b13;
    --kd-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---------- 00 Drawer shell (only for [kd_side_cart]; Off-Canvas widget does this itself) */
.kd-side-cart {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    visibility: hidden;
}
.kd-side-cart[data-open="true"] {
    visibility: visible;
}
.kd-side-cart[hidden] {
    display: block;
}
.kd-scrim {
    position: absolute;
    inset: 0;
    background: rgba(7, 11, 19, 0.5);
    opacity: 0;
    transition: opacity 0.3s;
}
.kd-side-cart[data-open="true"] .kd-scrim {
    opacity: 1;
}
.kd-panel {
    position: absolute;
    inset: 0 0 0 auto;
    width: min(440px, 100vw);
    background: var(--kd-surface);
    color: var(--kd-ink);
    transform: translateX(100%);
    transition: transform 0.34s var(--kd-ease);
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top, 0px);
    box-shadow: -20px 0 50px -30px rgba(12, 22, 39, 0.45);
}
.kd-side-cart[data-open="true"] .kd-panel {
    transform: none;
}
.kd-cart-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
}
body.kd-cart-lock {
    overflow: hidden;
}

/* ---------- 01 Header */
.kd-cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--kd-line);
}
.kd-cart-header h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.kd-close {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 0;
    background: none;
    color: var(--kd-ink);
    border-radius: 9px;
    cursor: pointer;
}
.kd-close:hover {
    background: var(--kd-canvas);
}
.kd-close svg {
    width: 20px;
    height: 20px;
}

/* ---------- 02 Items + 03 Free gift */
.kd-ci {
    display: flex;
    gap: 14px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--kd-line);
}
.kd-ci-thumb {
    width: 84px;
    height: 84px;
    flex: none;
    border-radius: 12px;
    overflow: hidden;
    background: var(--kd-canvas);
    display: block;
}
.kd-ci-thumb img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain;
    margin: 0 !important;
}
.kd-ci-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.kd-ci-row {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    align-items: flex-start;
}
.kd-ci-name {
    font-size: 0.94rem;
    font-weight: 700;
    line-height: 1.3;
}
.kd-ci-name a {
    color: inherit;
    text-decoration: none;
}
.kd-ci-meta {
    font-size: 0.8rem;
    color: var(--kd-muted);
}
.kd-ci-price {
    font-size: 0.94rem;
    font-weight: 700;
}
.kd-ci-price s {
    font-weight: 400;
    color: var(--kd-muted);
    margin-right: 6px;
}
.kd-ci-price .kd-free {
    color: var(--kd-brand);
}
.kd-ci-price .kd-ci-now {
    color: #0a7a32;
}
.kd-ci-discount {
    font-size: 0.78rem;
    font-weight: 600;
    color: #0a7a32;
}
.kd-ci-discount b {
    font-weight: 700;
    word-break: break-all;
}
.kd-ci-del {
    width: 36px;
    height: 36px;
    margin: -6px -8px 0 0;
    flex: none;
    border: 0;
    background: none;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--kd-muted);
    cursor: pointer;
}
.kd-ci-del:hover {
    color: var(--kd-ink);
    background: var(--kd-canvas);
}
.kd-ci-del svg {
    width: 17px;
    height: 17px;
}
.kd-qty {
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    border: 1px solid var(--kd-line);
    border-radius: 10px;
    margin-top: 4px;
}
.kd-qty button {
    width: 40px;
    height: 38px;
    border: 0;
    background: none;
    font-size: 1.05rem;
    color: var(--kd-ink);
    cursor: pointer;
}
.kd-qty span {
    min-width: 30px;
    text-align: center;
    font-size: 0.88rem;
    font-weight: 600;
}
/* Item details: product number, stock / delivery, price per piece */
.kd-ci-sku,
.kd-ci-stock {
    font-size: 0.78rem;
    color: var(--kd-muted);
    line-height: 1.35;
}
.kd-ci-stock--in-stock {
    color: #0a7a32;
}
.kd-ci-stock--available-on-backorder {
    color: #9a5b00;
}
.kd-ci-stock--out-of-stock {
    color: #b42318;
}
.kd-ci-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 6px;
}
.kd-ci-foot .kd-qty {
    margin-top: 0;
}
.kd-ci-foot .kd-ci-price {
    margin-left: auto;
    text-align: right;
    white-space: nowrap;
}
.kd-ci-unit {
    align-self: flex-end;
    text-align: right;
    font-size: 0.78rem;
    font-style: italic;
    color: var(--kd-muted);
}
.kd-ci-unit s {
    margin-right: 2px;
}
.kd-ci-pct {
    font-weight: 600;
    color: #0a7a32;
}
.kd-cart-gift {
    background: var(--kd-brand-lt);
}
.kd-cart-gift .kd-ci-thumb {
    background: var(--kd-surface);
    height: 68px;
}
.kd-tag {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--kd-brand-dk);
}
.kd-cart-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--kd-muted);
}
.kd-btn {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 18px;
    border-radius: 10px;
    background: var(--kd-brand);
    color: #fff !important;
    font-weight: 600;
    text-decoration: none;
    margin-top: 12px;
}
.kd-loading .kd-cart-items-wrap,
.kd-loading .kd-cart-upsell-wrap {
    opacity: 0.55;
    pointer-events: none;
    transition: opacity 0.2s;
}

/* ---------- 04 Upsell — "Complete your setup" */
.kd-cart-upsell-wrap:empty {
    display: none;
}
.kd-cart-upsell-wrap {
    padding: 20px 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.kd-ups-head h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.kd-ups-head p {
    margin: 2px 0 0;
    font-size: 0.8rem;
    color: var(--kd-muted);
}
.kd-ups-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.kd-up {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px;
    border: 1px solid var(--kd-line);
    border-radius: 14px;
    background: var(--kd-surface);
    transition: border-color 0.2s;
}
.kd-up:hover {
    border-color: #9dbcf0;
}
.kd-up .kd-ci-thumb {
    width: 58px;
    height: 58px;
    border-radius: 10px;
}
.kd-up-txt {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.kd-up-txt a {
    color: inherit;
    text-decoration: none;
}
.kd-up-txt > a b {
    font-size: 0.86rem;
    line-height: 1.3;
}
.kd-up-txt > span {
    font-size: 0.74rem;
    color: var(--kd-muted);
}
.kd-up-txt em {
    font-style: normal;
    font-size: 0.86rem;
    font-weight: 700;
    margin-top: 2px;
}
/* keep "€" and the amount together */
.kd-up-txt em .woocommerce-Price-amount {
    white-space: nowrap;
}
.kd-up-txt em del {
    font-weight: 400;
    color: var(--kd-muted);
}
.kd-up-txt em ins {
    text-decoration: none;
}
.kd-up-add {
    flex: none;
    min-width: 82px;
    height: 44px;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: var(--kd-brand);
    color: #fff !important;
    font-weight: 600;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}
.kd-up-add:hover {
    background: var(--kd-brand-dk);
}
.kd-up-add svg {
    width: 14px;
    height: 14px;
}
.kd-up-add.is-added {
    background: var(--kd-brand-lt);
    color: var(--kd-brand-dk) !important;
    box-shadow: inset 0 0 0 1px var(--kd-brand);
}

/* ---------- 05 Footer */
.kd-cart-footer {
    border-top: 1px solid var(--kd-line);
    background: var(--kd-canvas);
    padding: 14px 20px calc(18px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.kd-cart-trust {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 14px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--kd-ink-2);
}
.kd-cart-trust li::before {
    content: "✓";
    color: var(--kd-brand);
    margin-right: 5px;
}
.kd-cart-subtotal {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
}
.kd-cart-subtotal .kd-cart-subtotal-amt {
    font-weight: 700;
}
.kd-cart-discounts {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0 0 10px;
}
.kd-cart-discounts:empty {
    display: none;
}
.kd-cart-discount {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    font-size: 0.88rem;
    color: #0a7a32;
}
.kd-cart-discount .kd-cart-coupon {
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 5px;
    background: #e6f4ea;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #0a7a32;
    word-break: break-all;
}
.kd-cart-discount-amt {
    font-weight: 700;
    white-space: nowrap;
}
/* [kd_cart_checkout]: summary, discount code, checkout button, "View cart" */
.kd-cart-checkout-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
/* The summary has its own Subtotal row: hide the template's separate one */
.kd-cart-footer:has(.kd-cart-summary:not(:empty)) .kd-cart-subtotal.e-con,
.kd-cart-footer:has(.kd-cart-summary:not(:empty)) > .kd-cart-subtotal {
    display: none !important;
}
.kd-cart-summary {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.88rem;
    color: var(--kd-ink);
}
.kd-cart-summary:empty,
.kd-cart-coupon-wrap:empty {
    display: none;
}
.kd-sum-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}
.kd-sum-val {
    white-space: nowrap;
    text-align: right;
}
.kd-sum-row small {
    display: block;
    font-size: 0.74rem;
    color: var(--kd-muted);
}
.kd-sum-rrp {
    color: var(--kd-muted);
}
.kd-sum-save,
.kd-sum-save .kd-sum-val,
.kd-sum-free {
    font-weight: 700;
    color: #0a7a32;
}
.kd-sum-subtotal {
    font-weight: 700;
}
.kd-sum-later {
    font-size: 0.8rem;
    color: var(--kd-muted);
}
.kd-cart-summary .kd-cart-discounts {
    margin: 0;
}
.kd-sum-note {
    margin: 2px 0 0;
    font-size: 0.72rem;
    line-height: 1.4;
    color: var(--kd-muted);
}
.kd-sum-note--vat {
    margin-top: 0;
}
.kd-cart-coupon .kd-coupon-del {
    display: inline-grid;
    place-items: center;
    width: 16px;
    height: 16px;
    margin: 0 -2px 0 4px;
    vertical-align: -3px;
    cursor: pointer;
}
.kd-cart-coupon .kd-coupon-del svg {
    width: 12px;
    height: 12px;
}
.kd-coupon {
    display: flex;
    align-items: stretch;
    height: 44px;
    border: 1px dashed #b9c3d4;
    border-radius: 10px;
    background: var(--kd-surface);
    overflow: hidden;
}
.kd-coupon:focus-within {
    border-style: solid;
    border-color: var(--kd-brand);
}
.kd-coupon-field {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 0 0 12px;
    margin: 0;
    cursor: text;
}
.kd-coupon-field svg {
    width: 18px;
    height: 18px;
    flex: none;
    color: var(--kd-brand);
}
.kd-coupon-msg {
    margin: 6px 0 0;
    font-size: 0.78rem;
    line-height: 1.4;
}
.kd-coupon-msg:empty {
    display: none;
}
.kd-coupon-msg.is-error {
    color: #b42318;
}
.kd-coupon-msg.is-ok {
    color: #0a7a32;
}
.kd-view-cart {
    align-self: center;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--kd-brand) !important;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.kd-view-cart:hover {
    color: var(--kd-brand-dk) !important;
}
/* Elementor version of the footer (KD Header template): keep the Subtotal row and the
   payment logos in one row at every width, whatever the template's mobile settings or
   a stale CSS cache say. The logo container is the footer container holding Image widgets. */
.kd-cart-footer .kd-cart-subtotal.e-con {
    --flex-direction: row;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    align-items: center !important;
}
.kd-cart-footer .kd-cart-subtotal.e-con > .elementor-element {
    width: auto !important;
    margin: 0 !important;
}
.kd-cart-footer .kd-cart-subtotal.e-con p {
    margin: 0;
}
.kd-cart-footer .e-con:has(> .elementor-widget-image),
.kd-cart-footer .e-con-inner:has(> .elementor-widget-image) {
    --flex-direction: row;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 6px !important;
}
/* Image widgets placed straight in the footer (no logo container): the footer wraps as a row,
   every other child takes a full line, the logos share theirs. */
.kd-cart-footer:has(> .elementor-widget-image) {
    display: flex;
    --flex-direction: row;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: center !important;
    column-gap: 6px !important;
}
.kd-cart-footer:has(> .elementor-widget-image) > :not(.elementor-widget-image) {
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100% !important;
}
.kd-cart-footer .elementor-widget-image {
    width: auto !important;
    max-width: none !important;
    flex: none !important;
    margin: 0 !important;
}
.kd-cart-footer .elementor-widget-image img {
    display: block;
    height: 32px !important;
    width: auto !important;
    max-width: none !important;
}
.kd-checkout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 52px;
    border-radius: 12px;
    background: var(--kd-night);
    color: #fff !important;
    font-weight: 700;
    font-size: 0.94rem;
    text-decoration: none;
    transition: background 0.2s;
}
.kd-checkout:hover {
    background: var(--kd-brand-dk);
}
.kd-checkout svg {
    width: 16px;
    height: 16px;
}
.kd-checkout .woocommerce-Price-amount {
    color: inherit;
}
.kd-cart-payments {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}
.kd-cart-payments span {
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--kd-surface);
    border: 1px solid var(--kd-line);
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--kd-ink-2);
}

/* ---------- Header basket badge: [kd_cart_count] inside .kd-cart-trigger */
.kd-cart-trigger {
    position: relative;
}
.kd-cart-trigger .kd-cart-count {
    position: absolute;
    top: 2px;
    right: 0;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--kd-brand);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    display: grid;
    place-items: center;
    line-height: 1;
}
.kd-cart-trigger .kd-cart-count[data-count="0"] {
    display: none;
}

/* ---------- Elementor Off-Canvas: the middle container scrolls, header + footer stay put
   (root container: Direction Column, Min Height 100vh — see BUILD-MAP.md) */
.kd-cart-root {
    height: 100vh;
    height: 100dvh;
}
.kd-cart-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.kd-cart-root .kd-cart-footer,
.kd-cart-root .kd-cart-header {
    flex: none;
}

/* ---------- Mobile */
@media (max-width: 560px) {
    .kd-cart-header {
        padding: 8px 12px 8px 16px;
    }
    .kd-ci {
        padding: 14px 16px;
        gap: 12px;
    }
    .kd-ci-thumb {
        width: 72px;
        height: 72px;
    }
    .kd-cart-gift .kd-ci-thumb {
        height: 58px;
    }
    .kd-ci-name {
        font-size: 0.9rem;
    }
    .kd-cart-upsell-wrap {
        padding: 16px 0 18px;
        gap: 10px;
    }
    .kd-ups-head {
        padding: 0 16px;
    }
    .kd-ups-list {
        flex-direction: row;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: 10px;
        padding: 0 16px 6px;
        scroll-padding-left: 16px;
        scrollbar-width: none;
    }
    .kd-ups-list::-webkit-scrollbar {
        display: none;
    }
    /* card: picture + text side by side, the button full width underneath */
    .kd-up {
        flex: 0 0 min(280px, 82%);
        scroll-snap-align: start;
        display: grid;
        grid-template-columns: 58px minmax(0, 1fr);
        align-items: start;
        align-content: start;
        gap: 10px 12px;
    }
    .kd-up-txt > a b {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .kd-up-txt > span {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .kd-up-add {
        grid-column: 1 / -1;
        width: 100%;
        height: 40px !important;
    }
    /* payment logos take too much room on a phone */
    .kd-cart-payments,
    .kd-cart-footer .e-con:has(> .elementor-widget-image),
    .kd-cart-footer .e-con .e-con-inner:has(> .elementor-widget-image),
    .kd-cart-footer > .elementor-widget-image,
    .kd-cart-footer > .e-con-inner > .elementor-widget-image {
        display: none !important;
    }
    .kd-cart-footer {
        padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px));
        gap: 10px;
    }
    .kd-cart-trust {
        font-size: 0.7rem;
        gap: 2px 10px;
    }
    .kd-checkout {
        height: 50px;
    }
    .kd-cart-checkout-wrap {
        gap: 10px;
    }
    .kd-cart-summary {
        font-size: 0.84rem;
        gap: 4px;
    }
    .kd-sum-note--vat {
        display: none;
    }
    .kd-coupon {
        height: 42px;
    }
    .kd-cart-payments span {
        font-size: 0.62rem;
        padding: 2px 6px;
    }
}
@media (max-width: 360px) {
    .kd-cart-payments {
        display: none;
    }
}
@media (prefers-reduced-motion: reduce) {
    .kd-panel,
    .kd-scrim {
        transition: none;
    }
}

/* ---------- Theme / Elementor Kit button styles must not leak into the cart */
.kd-ci-del,
.kd-qty button,
.kd-close {
    background: none !important;
    border: 0 !important;
    box-shadow: none !important;
    color: var(--kd-ink) !important;
    padding: 0 !important;
    min-height: 0 !important;
    text-transform: none !important;
}
.kd-ci-del {
    color: var(--kd-muted) !important;
    border-radius: 8px !important;
}
.kd-ci-del:hover,
.kd-close:hover {
    background: var(--kd-canvas) !important;
    color: var(--kd-ink) !important;
}
.kd-qty button:hover {
    background: var(--kd-canvas) !important;
}
.kd-up-add {
    height: 44px !important;
    min-height: 0 !important;
    padding: 0 12px !important;
    border-radius: 10px !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    letter-spacing: 0 !important;
    background: var(--kd-brand) !important;
    color: #fff !important;
    border: 0 !important;
    box-shadow: none !important;
    text-transform: none !important;
    line-height: 1 !important;
}
.kd-up-txt > a b {
    font-size: 0.86rem !important;
    line-height: 1.3 !important;
    font-weight: 700;
}
.kd-up-txt > span {
    font-size: 0.74rem !important;
    line-height: 1.35 !important;
}
.kd-up-add:hover {
    background: var(--kd-brand-dk) !important;
}
.kd-up-add.is-added {
    background: var(--kd-brand-lt) !important;
    color: var(--kd-brand-dk) !important;
    box-shadow: inset 0 0 0 1px var(--kd-brand) !important;
}
.kd-coupon input[type="text"] {
    flex: 1;
    min-width: 0;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: none !important;
    box-shadow: none !important;
    outline: 0 !important;
    font: inherit !important;
    font-size: 0.9rem !important;
    color: var(--kd-ink) !important;
    text-transform: uppercase;
}
.kd-coupon input[type="text"]::placeholder {
    text-transform: none;
    color: var(--kd-muted);
}
.kd-coupon-apply {
    flex: none;
    width: 48px;
    display: grid !important;
    place-items: center;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: var(--kd-night) !important;
    color: #fff !important;
    box-shadow: none !important;
    cursor: pointer;
}
.kd-coupon-apply:hover {
    background: var(--kd-brand) !important;
}
.kd-coupon-apply svg {
    width: 18px;
    height: 18px;
}
.kd-coupon-del {
    padding: 0 !important;
    border: 0 !important;
    background: none !important;
    box-shadow: none !important;
    min-height: 0 !important;
    color: inherit !important;
}
