.cart-wrapper {
    position: relative;
    overflow: visible;
}

.cart-wrapper.is-open {
    z-index: 1201;
}

.cart-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--color-brown-900);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    padding: 0;
    position: relative;
}

.cart-btn:hover {
    background: rgba(18, 17, 15, 0.06);
}

.cart-count {
    position: absolute;
    top: -4px;
    inset-inline-start: -4px;
    background: #b94a48;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 100px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.cart-count.hidden {
    display: none;
}

.cart-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    right: auto;
    width: min(360px, calc(100vw - 40px));
    background: var(--color-bg);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-line);
    z-index: 1200;
    text-align: right;
    direction: rtl;
    overflow: hidden;
    transform-origin: top left;
    animation: cartDropdownIn 0.25s ease;
}

@keyframes cartDropdownIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cart-dropdown.hidden {
    display: none;
}

.cart-dropdown-header {
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--color-line);
    color: var(--color-brown-900);
    font-weight: 700;
    font-size: 1.05rem;
    background: var(--color-surface);
}

.cart-dropdown-body {
    max-height: 320px;
    overflow-y: auto;
    padding: 8px 0;
}

.cart-empty {
    padding: 28px 18px;
    text-align: center;
    color: #8a6a3b;
    font-size: 0.95rem;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px dashed #f0e6d8;
}

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

.cart-item-image {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
}

.cart-item-info {
    flex-grow: 1;
    min-width: 0;
}

.cart-item-name {
    color: #3d2b1f;
    font-weight: 700;
    font-size: 0.92rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item-price {
    color: #12110F;
    font-weight: 700;
    font-size: 0.88rem;
}

.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.cart-item-actions button {
    background: #ECE6E1;
    border: 1px solid #F2EDE8;
    color: #3d2b1f;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
    line-height: 1;
    padding: 0;
}

.cart-item-actions button:hover {
    background: #F2EDE8;
}

.cart-item-actions .cart-item-qty {
    min-width: 20px;
    text-align: center;
    font-weight: 700;
    font-size: 0.88rem;
    color: #3d2b1f;
}

.cart-item-remove {
    background: transparent;
    border: none;
    color: #b94a48;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    flex-shrink: 0;
    line-height: 1;
}

.cart-item-remove:hover {
    color: #8a3533;
}

.cart-dropdown-footer {
    padding: 14px 18px 18px;
    border-top: 1px solid var(--color-line);
    background: var(--color-surface);
}

.cart-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    color: #5a3e2b;
    font-size: 0.95rem;
}

.cart-total-row .cart-total-value {
    color: #6f4e37;
    font-weight: 700;
    font-size: 1.05rem;
}

.cart-checkout-link {
    display: block;
    width: 100%;
    box-sizing: border-box;
    background: #12110F;
    color: #fff;
    text-align: center;
    text-decoration: none;
    border-radius: 100px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    transition: background 0.2s ease;
}

.cart-checkout-link:hover {
    background: #2b2825;
}

.cart-checkout-link.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.cart-checkout-link + .cart-checkout-link {
    margin-top: 8px;
    background: #ECE6E1;
    color: #6f4e37;
    border: 1px solid #F2EDE8;
}

.cart-checkout-link + .cart-checkout-link:hover {
    background: #F2EDE8;
}

.card-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.card-actions-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.product-qty-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #ECE6E1;
    border: 1px solid #F2EDE8;
    border-radius: 100px;
    padding: 4px 6px;
    flex-shrink: 0;
}

.product-qty-controls button {
    width: 28px;
    height: 28px;
    border: none;
    background: #fff;
    color: #6f4e37;
    border-radius: 50%;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease;
    padding: 0;
}

.product-qty-controls button:hover {
    background: #F2EDE8;
}

.product-qty-value {
    min-width: 20px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: #3d2b1f;
}

#detail-actions.hidden {
    display: none;
}

.add-to-cart-btn {
    display: inline-block;
    background: #fff;
    color: #6f4e37;
    text-align: center;
    border: 1.5px solid #6f4e37;
    border-radius: 100px;
    padding: 7px 14px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.add-to-cart-btn:hover {
    background: #12110F;
    color: #fff;
}

.add-to-cart-btn.added {
    background: #e6f4ea;
    border-color: #1e7a3a;
    color: #1e7a3a;
}

.card-actions-row .buy-btn {
    margin-top: 0;
    flex: 1;
    box-sizing: border-box;
    text-align: center;
}

@media (max-width: 768px) {
    .cart-dropdown {
        position: fixed;
        top: 72px;
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        transform-origin: top center;
    }
}
