/* ============================================================
   Swift Checkout – Side Cart Drawer
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
    --swiftc-drawer-width: 400px;
    --swiftc-drawer-z: 99999;
}

/* ── Overlay ────────────────────────────────────────────────── */
.swiftc-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    -webkit-backdrop-filter: blur(1px);
    backdrop-filter: blur(1px);
}

.swiftc-drawer-overlay--visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ── Drawer panel ───────────────────────────────────────────── */
.swiftc-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--swiftc-drawer-width);
    max-width: 100vw;
    height: 100%;
    background: #fff;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -4px 0 32px rgba(0, 0, 0, 0.12);
    outline: none;
}

.swiftc-drawer--open {
    transform: translateX(0);
}


/* Hide floating trigger while drawer is open (sibling combinator — drawer
   is output before the button in render_drawer()) */
.swiftc-drawer--open ~ .swiftc-cart-trigger {
    opacity: 0;
    pointer-events: none;
}

/* ── Header ─────────────────────────────────────────────────── */
.swiftc-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.swiftc-drawer__title {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    margin: 0;
    line-height: 1.3;
}

.swiftc-drawer__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    cursor: pointer;
    color: #374151;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

.swiftc-drawer__close:hover {
    background: #e5e7eb;
    color: #111827;
}

.swiftc-drawer__close:focus-visible {
    outline: 2px solid var(--swiftc-primary, #2563eb);
    outline-offset: 2px;
}

/* ── Body (scrollable items) ────────────────────────────────── */
.swiftc-drawer__body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0;
}

.swiftc-drawer__body::-webkit-scrollbar {
    width: 4px;
}
.swiftc-drawer__body::-webkit-scrollbar-track {
    background: transparent;
}
.swiftc-drawer__body::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

/* ── Empty state ────────────────────────────────────────────── */
.swiftc-drawer__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    color: #9ca3af;
    gap: 12px;
}

.swiftc-drawer__empty p {
    margin: 0;
    font-size: 15px;
    color: #6b7280;
}

/* ── Cart items ─────────────────────────────────────────────── */
.swiftc-drawer-items {
    padding: 8px 0;
}

.swiftc-drawer-item {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 14px;
    align-items: start;
    padding: 16px 40px 16px 24px;
    border-bottom: 1px solid #f3f4f6;
    position: relative;
    transition: background 0.15s ease;
}

.swiftc-drawer-item:last-child {
    border-bottom: none;
}

.swiftc-drawer-item:hover {
    background: #fafafa;
}

.swiftc-drawer-item__img-link {
    display: block;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    line-height: 0;
}

.swiftc-drawer-item__img-link img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    display: block;
}

.swiftc-drawer-item__body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.swiftc-drawer-item__name {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    text-decoration: none;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.swiftc-drawer-item__name:hover {
    color: var(--swiftc-primary, #2563eb);
}

.swiftc-drawer-item__price {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
}

.swiftc-drawer-item__controls {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    width: fit-content;
    margin-top: 2px;
}

.swiftc-drawer-item__controls .swiftc-qty-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    background: #fff;
    cursor: pointer;
    font-size: 16px;
    color: #374151;
    transition: background 0.15s ease;
    line-height: 1;
}

.swiftc-drawer-item__controls .swiftc-qty-btn:hover {
    background: #f3f4f6;
    color: #111827;
}

.swiftc-drawer-item__controls .swiftc-qty-value {
    min-width: 28px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #111827;
    padding: 0 4px;
    border-left: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
    line-height: 30px;
}

#swiftc-drawer .swiftc-drawer-item__remove {
    position: absolute !important;
    top: 12px !important;
    right: 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 24px !important;
    height: 24px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 4px !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer !important;
    color: #9ca3af !important;
    line-height: 1 !important;
    transition: background 0.15s ease, color 0.15s ease;
}

#swiftc-drawer .swiftc-drawer-item__remove svg {
    display: block !important;
    width: 14px !important;
    height: 14px !important;
    stroke: currentColor !important;
    fill: none !important;
    pointer-events: none;
}

#swiftc-drawer .swiftc-drawer-item__remove:hover {
    background: #fee2e2 !important;
    color: #dc2626 !important;
}

/* ── Footer ─────────────────────────────────────────────────── */
.swiftc-drawer__footer {
    border-top: 1px solid #e5e7eb;
    padding: 20px 24px;
    flex-shrink: 0;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Totals ─────────────────────────────────────────────────── */
.swiftc-drawer-totals {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.swiftc-drawer-totals__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 15px;
}

.swiftc-drawer-totals__row--subtotal {
    font-weight: 700;
    font-size: 16px;
    color: #111827;
}

.swiftc-drawer-totals__note {
    margin: 4px 0 0;
    font-size: 12px;
    color: #9ca3af;
}

/* ── Checkout button ────────────────────────────────────────── */
.swiftc-drawer__checkout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 10px;
    background: var(--swiftc-primary, #2563eb);
    color: #fff;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.1s ease;
    text-align: center;
}

.swiftc-drawer__checkout:hover {
    opacity: 0.9;
    color: #fff;
    text-decoration: none;
}

.swiftc-drawer__checkout:active {
    transform: scale(0.98);
}

.swiftc-drawer__view-cart {
    display: block;
    text-align: center;
    font-size: 13px;
    color: #6b7280;
    text-decoration: underline;
    transition: color 0.15s ease;
}

.swiftc-drawer__view-cart:hover {
    color: #374151;
}

/* ── Discount row ───────────────────────────────────────────── */
.swiftc-drawer-totals__row--discount {
    color: #16a34a;
    font-size: 14px;
    font-weight: 600;
}

.swiftc-discount-amount {
    color: #16a34a;
}

/* ── Coupon section ─────────────────────────────────────────── */
.swiftc-drawer-coupon {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Applied coupon tags */
.swiftc-coupon-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.swiftc-coupon-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px 3px 10px;
    background: #dcfce7;
    color: #15803d;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid #bbf7d0;
    line-height: 1;
}

.swiftc-coupon-tag__code {
    letter-spacing: 0.03em;
}

#swiftc-drawer .swiftc-coupon-tag__remove {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 16px !important;
    height: 16px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 50% !important;
    background: transparent !important;
    box-shadow: none !important;
    cursor: pointer !important;
    color: #15803d !important;
    line-height: 1 !important;
    flex-shrink: 0;
    transition: background 0.1s ease, color 0.1s ease;
}

#swiftc-drawer .swiftc-coupon-tag__remove:hover {
    background: #bbf7d0 !important;
    color: #166534 !important;
}

#swiftc-drawer .swiftc-coupon-tag__remove svg {
    display: block !important;
    pointer-events: none;
}

/* Coupon input form */
.swiftc-coupon-form {
    display: flex;
    gap: 6px;
}

.swiftc-coupon-input {
    flex: 1;
    min-width: 0;
    height: 38px;
    padding: 0 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    color: #111827;
    background: #fff;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.swiftc-coupon-input::placeholder {
    color: #9ca3af;
}

.swiftc-coupon-input:focus {
    border-color: var(--swiftc-primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

#swiftc-drawer .swiftc-coupon-submit {
    height: 38px !important;
    padding: 0 14px !important;
    border: none !important;
    border-radius: 8px !important;
    background: #f3f4f6 !important;
    color: #374151 !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    box-shadow: none !important;
    transition: background 0.15s ease, color 0.15s ease;
    flex-shrink: 0;
}

#swiftc-drawer .swiftc-coupon-submit:hover {
    background: #e5e7eb !important;
    color: #111827 !important;
}

#swiftc-drawer .swiftc-coupon-submit:disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
}

/* Feedback message */
.swiftc-coupon-msg {
    font-size: 12px;
    line-height: 1.4;
    min-height: 0;
    margin: 0;
}

.swiftc-coupon-msg:empty {
    display: none;
}

.swiftc-coupon-msg--error {
    color: #dc2626;
}

.swiftc-coupon-msg--success {
    color: #16a34a;
}

/* ── Loading state ──────────────────────────────────────────── */
.swiftc-drawer--loading .swiftc-drawer__body {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

/* ── Floating trigger button ────────────────────────────────── */

/* ID selector for position/offset/z-index — specificity (1,0,0) beats any
   theme rule that targets buttons by class or element selector */
#swiftc-cart-trigger {
    position: fixed;
    bottom: 28px;
    right: 28px;
    left: auto;
    top: auto;
    z-index: 999999;
}

.swiftc-cart-trigger {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--swiftc-primary, #2563eb);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.swiftc-cart-trigger:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}

.swiftc-cart-trigger:active {
    transform: scale(0.96);
}

.swiftc-cart-trigger:focus-visible {
    outline: 3px solid var(--swiftc-primary, #2563eb);
    outline-offset: 3px;
}

/* Count badge — shown only when cart has items */
.swiftc-cart-trigger__count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    border: 2px solid #fff;
}

.swiftc-cart-trigger--has-items .swiftc-cart-trigger__count {
    display: flex;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 480px) {
    :root {
        --swiftc-drawer-width: 100vw;
    }

    #swiftc-cart-trigger {
        bottom: 20px;
        right: 20px;
    }

    .swiftc-drawer-item {
        padding: 14px 16px;
        gap: 12px;
    }

    .swiftc-drawer__header,
    .swiftc-drawer__footer {
        padding: 16px;
    }
}
