/* ==========================================================================
   WESTORX Cart Drawer
   Uses theme CSS variables from style.css (--color-black, --color-accent, etc.)
   ========================================================================== */

/* Overlay */
.wstx-cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 10, 0.55);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity .35s ease, visibility .35s ease;
}
.wstx-cart-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* Drawer panel */
.wstx-cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 100%;
    max-width: 440px;
    background: var(--color-white);
    z-index: 9999;
    transform: translateX(105%);
    transition: transform .4s cubic-bezier(.4, 0, .2, 1);
    box-shadow: -20px 0 50px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.wstx-cart-drawer.open {
    transform: translateX(0);
}

.wstx-cart-drawer-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

/* Header */
.wstx-cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 24px;
    border-bottom: 1px solid var(--color-gray-2);
    flex-shrink: 0;
}
.wstx-cart-title {
    font-family: var(--font-secondary);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--color-black);
    margin: 0;
    letter-spacing: .02em;
}
.wstx-cart-count-label {
    font-family: var(--font-primary);
    font-size: .85rem;
    color: var(--color-gray-3);
    font-weight: 500;
    margin-left: 4px;
}
.wstx-cart-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--color-black);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition);
}
.wstx-cart-close:hover {
    color: var(--color-accent);
}

/* Free shipping bar */
.wstx-shipping-bar {
    padding: 16px 24px;
    background: #faf8f4;
    border-bottom: 1px solid var(--color-gray-2);
    flex-shrink: 0;
}
.wstx-shipping-msg {
    font-size: .8rem;
    color: #444;
    margin: 0 0 10px 0;
    letter-spacing: .02em;
    text-align: center;
}
.wstx-shipping-msg strong {
    color: var(--color-black);
    font-weight: 700;
}
.wstx-shipping-msg.wstx-shipping-unlocked {
    color: #2d7a2d;
}
.wstx-shipping-msg.wstx-shipping-unlocked strong {
    color: #2d7a2d;
}
.wstx-shipping-progress {
    height: 4px;
    background: #e8e3d7;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}
.wstx-shipping-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-accent), #d4b87c);
    border-radius: 2px;
    transition: width .5s cubic-bezier(.4, 0, .2, 1);
}

/* Items list */
.wstx-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px;
    scrollbar-width: thin;
    scrollbar-color: var(--color-gray-2) transparent;
}
.wstx-cart-items::-webkit-scrollbar { width: 6px; }
.wstx-cart-items::-webkit-scrollbar-track { background: transparent; }
.wstx-cart-items::-webkit-scrollbar-thumb { background: var(--color-gray-2); border-radius: 3px; }

/* Single item */
.wstx-cart-item {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: 14px;
    padding: 18px 0;
    border-bottom: 1px solid var(--color-gray-1);
    position: relative;
}
.wstx-cart-item:last-child {
    border-bottom: none;
}
.wstx-cart-item-img {
    display: block;
    width: 80px;
    height: 80px;
    overflow: hidden;
    background: var(--color-gray-1);
    flex-shrink: 0;
}
.wstx-cart-item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.wstx-cart-item-body {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}
.wstx-cart-item-name {
    font-size: .85rem;
    font-weight: 600;
    color: var(--color-black);
    text-decoration: none;
    line-height: 1.35;
    margin-bottom: 4px;
    display: block;
    transition: color var(--transition);
}
.wstx-cart-item-name:hover {
    color: var(--color-accent);
}
.wstx-cart-item-variation {
    font-size: .7rem;
    color: var(--color-gray-3);
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-bottom: 8px;
}
.wstx-cart-item-variation span {
    color: var(--color-black);
    font-weight: 600;
}
.wstx-cart-item-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
}

/* Qty controls inside drawer */
.wstx-cart-qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--color-gray-2);
    background: var(--color-white);
}
.wstx-cart-qty button {
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--color-black);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s ease, color .2s ease;
    user-select: none;
}
.wstx-cart-qty button:hover {
    background: var(--color-black);
    color: var(--color-white);
}
.wstx-cart-qty .wstx-qty-val {
    width: 28px;
    height: 28px;
    border: none;
    border-left: 1px solid var(--color-gray-2);
    border-right: 1px solid var(--color-gray-2);
    text-align: center;
    font-size: .8rem;
    font-weight: 600;
    background: transparent;
    padding: 0;
}
.wstx-cart-item-price {
    font-size: .9rem;
    font-weight: 700;
    color: var(--color-black);
    white-space: nowrap;
}
.wstx-cart-item-remove {
    align-self: flex-start;
    color: var(--color-gray-3);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    transition: color var(--transition);
    text-decoration: none;
    display: inline-flex;
}
.wstx-cart-item-remove:hover {
    color: #d04545;
}

/* Empty state */
.wstx-cart-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-gray-3);
}
.wstx-cart-empty svg {
    color: var(--color-gray-2);
    margin-bottom: 18px;
}
.wstx-cart-empty-title {
    font-family: var(--font-secondary);
    font-size: 1.25rem;
    color: var(--color-black);
    margin: 0 0 6px 0;
}
.wstx-cart-empty-text {
    font-size: .85rem;
    margin: 0 0 22px 0;
}

/* Footer */
.wstx-cart-footer {
    padding: 20px 24px 28px;
    border-top: 1px solid var(--color-gray-2);
    background: var(--color-white);
    flex-shrink: 0;
}
.wstx-cart-subtotal {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: .95rem;
    margin-bottom: 6px;
}
.wstx-cart-subtotal span {
    color: #444;
    text-transform: uppercase;
    font-weight: 600;
    font-size: .75rem;
    letter-spacing: .15em;
}
.wstx-cart-subtotal strong {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-black);
}
.wstx-cart-note {
    font-size: .7rem;
    color: var(--color-gray-3);
    margin: 0 0 16px 0;
    letter-spacing: .03em;
}
.wstx-cart-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Drawer buttons */
.wstx-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 46px;
    padding: 0 18px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .2em;
    text-transform: uppercase;
    text-decoration: none;
    border: 1px solid var(--color-black);
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    text-align: center;
}
.wstx-btn-primary {
    background: var(--color-black);
    color: var(--color-white);
}
.wstx-btn-primary:hover {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-white);
}
.wstx-btn-outline {
    background: var(--color-white);
    color: var(--color-black);
}
.wstx-btn-outline:hover {
    background: var(--color-black);
    color: var(--color-white);
}

/* Loading state */
.wstx-cart-drawer.is-loading .wstx-cart-items {
    opacity: .5;
    pointer-events: none;
}
.wstx-cart-drawer.is-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 36px;
    height: 36px;
    margin: -18px 0 0 -18px;
    border: 3px solid var(--color-gray-2);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: wstx-spin .8s linear infinite;
    z-index: 10;
}
@keyframes wstx-spin {
    to { transform: rotate(360deg); }
}

/* Body scroll lock */
body.wstx-cart-open {
    overflow: hidden;
}

/* Mobile */
@media (max-width: 480px) {
    .wstx-cart-drawer {
        max-width: 100%;
    }
    .wstx-cart-header {
        padding: 18px 20px;
    }
    .wstx-shipping-bar,
    .wstx-cart-items,
    .wstx-cart-footer {
        padding-left: 20px;
        padding-right: 20px;
    }
    .wstx-cart-actions {
        grid-template-columns: 1fr;
    }
}
