/**
 * Shopify Cart Widget Styles
 *
 * Cart icon (header), badge, slide-out drawer, line items.
 */

/* ── Header Icons Container ───────────────────────────────────────────── */

.sp-header-icons {
    display: flex;
    align-items: center;
    gap: 0;
    margin: 0 !important;
}

/* ── Account Icon ─────────────────────────────────────────────────────── */

.sp-account-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    color: inherit;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.sp-account-icon-wrapper:hover {
    opacity: 0.7;
}

.sp-account-icon-wrapper svg {
    width: 22px;
    height: 22px;
}

/* ── Cart Icon ────────────────────────────────────────────────────────── */

.sp-cart-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    cursor: pointer;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    line-height: 1;
    transition: opacity 0.2s ease;
}

.sp-cart-icon-wrapper:hover {
    opacity: 0.7;
}

.sp-cart-icon-wrapper svg {
    width: 44px;
    height: 48px;
}

/* ── Badge (matches Shopify Dawn .cart-count-bubble) ──────────────────── */

.sp-cart-badge {
    position: absolute;
    bottom: 9px;
    right: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 19px;
    height: 19px;
    padding: 0;
    border-radius: 100%;
    background-color: rgb(158, 95, 36);
    color: rgb(243, 243, 243);
    font-size: 10px;
    font-weight: 400;
    line-height: 11px;
    text-align: center;
    pointer-events: none;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.sp-cart-badge:empty,
.sp-cart-badge[data-count="0"] {
    display: none;
}

/* ── Overlay ──────────────────────────────────────────────────────────── */

.sp-cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sp-cart-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* ── Drawer ───────────────────────────────────────────────────────────── */

.sp-cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    height: 100dvh;
    background: #fff;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: #1a1a1a;
}

.sp-cart-drawer.is-open {
    transform: translateX(0);
}

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

.sp-cart-drawer__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #1a1a1a;
}

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

.sp-cart-drawer__close:hover {
    background-color: #f0f0f0;
    color: #1a1a1a;
}

/* Body */
.sp-cart-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    -webkit-overflow-scrolling: touch;
}

/* Empty state */
.sp-cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    color: #888;
}

.sp-cart-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
    stroke: currentColor;
    fill: none;
}

.sp-cart-empty p {
    margin: 0 0 20px;
    font-size: 15px;
    line-height: 1.5;
}

.sp-cart-empty a {
    display: inline-block;
    padding: 10px 24px;
    background: #1a1a1a;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.15s ease;
}

.sp-cart-empty a:hover {
    background: #333;
}

/* Loading state */
.sp-cart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    color: #888;
}

.sp-cart-loading__spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #e8e8e8;
    border-top-color: #1a1a1a;
    border-radius: 50%;
    animation: sp-cart-spin 0.6s linear infinite;
}

@keyframes sp-cart-spin {
    to { transform: rotate(360deg); }
}

/* Line Items */
.sp-cart-items {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sp-cart-item {
    display: flex;
    gap: 14px;
    padding: 16px 24px;
    border-bottom: 1px solid #f0f0f0;
}

.sp-cart-item:last-child {
    border-bottom: none;
}

.sp-cart-item__image {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border-radius: 8px;
    overflow: hidden;
    background: #f7f7f7;
}

.sp-cart-item__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sp-cart-item__details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sp-cart-item__title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    color: #1a1a1a;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.sp-cart-item__title a {
    color: inherit;
    text-decoration: none;
}

.sp-cart-item__title a:hover {
    text-decoration: underline;
}

.sp-cart-item__variant {
    font-size: 12px;
    color: #888;
    margin: 0;
}

.sp-cart-item__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.sp-cart-item__quantity {
    font-size: 13px;
    color: #666;
}

.sp-cart-item__price {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
}

/* Footer */
.sp-cart-drawer__footer {
    flex-shrink: 0;
    padding: 20px 24px;
    border-top: 1px solid #e8e8e8;
    background: #fafafa;
}

.sp-cart-drawer__subtotal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1a1a1a;
}

.sp-cart-drawer__note {
    font-size: 12px;
    color: #888;
    margin: 0 0 16px;
}

.sp-cart-drawer__actions {
    display: flex;
    gap: 10px;
}

.sp-cart-drawer__btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    border: none;
    line-height: 1.2;
}

.sp-cart-drawer__btn--primary {
    background: #1a1a1a;
    color: #fff;
}

.sp-cart-drawer__btn--primary:hover {
    background: #333;
    color: #fff;
}

.sp-cart-drawer__btn--secondary {
    background: #fff;
    color: #1a1a1a;
    border: 1px solid #d0d0d0;
}

.sp-cart-drawer__btn--secondary:hover {
    background: #f5f5f5;
    color: #1a1a1a;
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .sp-cart-drawer {
        width: 100vw;
        max-width: 100vw;
    }

    .sp-cart-drawer__header {
        padding: 16px 18px;
    }

    .sp-cart-item {
        padding: 14px 18px;
    }

    .sp-cart-item__image {
        width: 60px;
        height: 60px;
    }

    .sp-cart-drawer__footer {
        padding: 16px 18px;
    }

    .sp-cart-drawer__actions {
        flex-direction: column;
    }
}

/* ── Prevent body scroll when drawer is open ──────────────────────────── */

body.sp-cart-open {
    overflow: hidden;
}
