.flex-column {
    flex-direction: column;
}

.cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    max-width: 90vw;
    height: 100vh;
    height: 100dvh;
    background: var(--color-bg-white);
    box-shadow: var(--shadow-drawer);
    z-index: 99999999 !important;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    transform: translateX(101%);
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

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

.cart-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--color-border-light);
    padding-bottom: 14px;
    margin-bottom: 14px;
    flex-shrink: 0;
}

.cart-drawer-header span {
    font-size: 14px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cart-drawer-content {
    display: flex;
    flex-direction: column;
    overflow-y: hidden;
    flex: 1 1 auto;
    min-height: 0;
}

.cart-drawer-empty {
    flex: 1 1 auto;
}

.cart-drawer-items-list::-webkit-scrollbar {
    width: 3px;
}

.cart-drawer-items-list::-webkit-scrollbar-thumb {
    background-color: #ddd;
    border-radius: var(--radius-sm);
}


.cart-drawer-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.cart-drawer-loader.active {
    visibility: visible;
    opacity: 1;
}

.cart-drawer-loader .spinner {
    border: 2px solid #f0f0f0;
    border-top-color: var(--color-primary);
    border-radius: var(--radius-circle);
    width: 28px;
    height: 28px;
    animation: spin 0.7s linear infinite;
}

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

.cart-drawer-items-list {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex: 0 1 auto;
    min-height: 0;
    padding-right: 4px;
}

.cart-drawer-item {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--color-border-light, #f0f0f0);
}

.cart-drawer-item:first-child {
    padding-top: 2px;
}

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

.cart-drawer-item-img {
    width: 68px;
    height: 68px;
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
    border: 1px solid var(--color-border-light, #f0f0f0);
    flex-shrink: 0;
    background: #fafafa;
}

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

.cart-drawer-item-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cart-drawer-item-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.cart-drawer-item-name {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--color-text-main);
    margin: 0;
    padding: 0;
}

.cart-drawer-item-name a {
    color: inherit;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-drawer-item-name a:hover {
    color: var(--color-primary);
}

.cart-drawer-item-variation {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-muted, #888);
}

.cart-drawer-item-price {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 13px;
    margin: 0;
    line-height: 1.4;
}

.cart-drawer-item-price .price-compare {
    font-size: 11px;
    font-weight: 400;
    text-decoration: line-through;
    color: #999;
}

.cart-drawer-item-price .price-active {
    font-weight: 700;
    color: var(--color-primary);
}

.cart-drawer-item-price-qty {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
}

.cart-drawer .quantity-control {
    display: flex;
    align-items: stretch;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-md);
    background: var(--color-bg-white);
    height: 32px;
    overflow: hidden;
    flex-shrink: 0;
}

.cart-drawer .quantity-control .qty-minus,
.cart-drawer .quantity-control .qty-plus {
    width: 32px;
    height: 100%;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #111827;
    font-weight: 700;
    flex-shrink: 0;
    padding: 0;
    margin: 0;
    line-height: 1;
    user-select: none;
    -webkit-user-select: none;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.cart-drawer .quantity-control .qty-minus:hover,
.cart-drawer .quantity-control .qty-plus:hover {
    color: var(--color-primary);
    background-color: #fafafa;
}

.cart-drawer .quantity-control .qty-input {
    width: 36px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none !important;
    border-left: 1px solid #e5e7eb !important;
    border-right: 1px solid #e5e7eb !important;
    text-align: center;
    font-weight: 800;
    font-size: 0.9rem;
    color: #111827;
    background: var(--color-bg-white);
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    box-sizing: border-box;
    outline: none;
    pointer-events: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

.cart-drawer .quantity-control .qty-input::-webkit-inner-spin-button,
.cart-drawer .quantity-control .qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.btn-close-cart-drawer {
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    color: var(--color-text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    transition: color 0.15s ease;
}

.btn-close-cart-drawer:hover {
    color: var(--color-primary);
}

.cart-drawer-remove-btn {
    flex-shrink: 0;
    border: none;
    background: none;
    padding: 2px;
    cursor: pointer;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}

.cart-drawer-remove-btn:hover {
    color: var(--color-primary);
}

.cart-drawer-remove-btn svg {
    width: 14px;
    height: 14px;
}

.cart-drawer-footer {
    flex-shrink: 0;
    /* Pushes the footer to the true bottom of the drawer when there are few
       items, while still letting .cart-drawer-items-list scroll internally
       and keep the footer visible when there are many. */
    margin-top: auto;
    padding-top: 14px;
    background: var(--color-bg-white);
    border-top: 1px solid var(--color-border-light, #f0f0f0);
    box-sizing: border-box;
}

.cart-drawer-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.cart-drawer-summary span:first-child {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-main);
}

.cart-drawer-summary span:last-child {
    font-size: 15px;
    font-weight: 800;
    color: var(--color-primary);
}

.cart-drawer-buttons {
    display: flex;
    flex-direction: column;
}

.cart-drawer-buttons .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 36px;
    padding: 0 16px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: opacity 0.2s ease;
    text-decoration: none;
    box-sizing: border-box;
}

.cart-drawer-buttons .btn:hover {
    opacity: 0.9;
}

.cart-drawer-buttons .btn svg {
    width: 14px;
    height: 14px;
}

.cart-drawer-buttons .btn svg path {
    stroke: currentColor;
}

.cart-drawer-buttons .btn svg circle {
    fill: currentColor;
}

.cart-drawer-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
    text-align: center;
}

.cart-drawer-empty .btn {
    min-height: 0;
    padding: 8px 20px;
}

.cart-drawer-overlay {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.45);
    z-index: 99999998 !important;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

body.cart-drawer-open .cart-drawer-overlay {
    opacity: 1;
    visibility: visible;
}

.cart-drawer-empty-icon {
    color: #ccc;
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.cart-drawer-empty-icon svg {
    width: 64px;
    height: 64px;
}

.cart-drawer-empty-icon svg path {
    stroke: currentColor;
}

.cart-drawer-empty-icon svg circle {
    fill: currentColor;
}

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

@media (max-width: 480px) {
    .cart-drawer {
        width: 320px;
        max-width: 85vw;
        padding: 16px;
    }

    .cart-drawer-item-img {
        width: 56px;
        height: 56px;
    }

    .cart-drawer-item-name {
        font-size: 10px;
    }

    .cart-drawer-buttons .btn {
        height: 32px;
        font-size: 11px;
    }
}
