/* Cart Dropdown Styles */
.cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: var(--accent-gold);
    color: var(--primary-black);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Cart Dropdown */
.cart-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 350px;
    background-color: var(--secondary-black);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.cart-icon {
    position: relative;
}

.cart-icon:hover .cart-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.cart-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(212, 175, 55, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-header h3 {
    color: var(--pure-white);
    font-size: 1.2rem;
}

.cart-items {
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem;
}

/* Scrollbar Styling untuk Cart Items */
.cart-items::-webkit-scrollbar {
    width: 6px;
}

.cart-items::-webkit-scrollbar-track {
    background: var(--primary-black);
    border-radius: 3px;
}

.cart-items::-webkit-scrollbar-thumb {
    background: var(--accent-gold);
    border-radius: 3px;
}

.cart-items::-webkit-scrollbar-thumb:hover {
    background: var(--light-gold);
}

.cart-item {
    display: flex;
    padding: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background-color 0.3s;
}

.cart-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.cart-item-img {
    width: 60px;
    height: 60px;
    background-color: var(--primary-black);
    border-radius: 4px;
    overflow: hidden;
    margin-right: 1rem;
    flex-shrink: 0;
}

.cart-item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-item-details {
    flex: 1;
    min-width: 0; /* Penting untuk mencegah overflow */
}

.cart-item-title {
    color: var(--pure-white);
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-price {
    color: var(--accent-gold);
    font-weight: 600;
    font-size: 0.9rem;
}

.cart-item-quantity {
    display: flex;
    align-items: center;
    margin-top: 0.5rem;
}

.quantity-btn {
    background-color: var(--primary-black);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: var(--text-gray);
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s;
    flex-shrink: 0;
}

.quantity-btn:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.quantity-input {
    width: 40px;
    text-align: center;
    background-color: transparent;
    border: none;
    color: var(--text-gray);
    margin: 0 0.5rem;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.cart-item-remove {
    color: #ff6b6b;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    margin-left: 0.5rem;
    transition: color 0.3s;
    flex-shrink: 0;
}

.cart-item-remove:hover {
    color: #ff5252;
}

.cart-footer {
    padding: 1rem;
    border-top: 1px solid rgba(212, 175, 55, 0.1);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-weight: 600;
}

.cart-total span:first-child {
    color: var(--text-gray);
}

.cart-total span:last-child {
    color: var(--accent-gold);
    font-size: 1.2rem;
}

.cart-actions {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.cart-btn {
    display: inline-block;
    padding: 0.6rem 0.8rem;
    background-color: var(--accent-gold);
    color: var(--primary-black);
    text-decoration: none;
    font-weight: 600;
    border-radius: 4px;
    transition: all 0.3s;
    border: none;
    cursor: pointer;
    text-align: center;
    flex: 1;
    font-size: 0.85rem;
    white-space: nowrap;
    min-width: 0;
}

.cart-btn:hover {
    background-color: var(--light-gold);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(212, 175, 55, 0.3);
}

.cart-btn-outline {
    background-color: transparent;
    border: 2px solid var(--accent-gold);
    color: var(--accent-gold);
    padding: 0.5rem 0.7rem;
}

.cart-btn-outline:hover {
    background-color: var(--accent-gold);
    color: var(--primary-black);
}

.empty-cart {
    padding: 2rem;
    text-align: center;
    color: var(--text-gray);
}

.empty-cart i {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: rgba(255, 255, 255, 0.2);
}

/* Animation untuk cart item saat dihapus */
.cart-item-removing {
    animation: slideOut 0.3s ease forwards;
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
        max-height: 100px;
    }
    to {
        opacity: 0;
        transform: translateX(100%);
        max-height: 0;
        padding: 0;
        margin: 0;
        border: none;
    }
}

/* Loading state untuk cart */
.cart-loading {
    position: relative;
    pointer-events: none;
}

.cart-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid var(--accent-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* PERBAIKAN RESPONSIF UNTUK MOBILE */
@media (max-width: 768px) {
    .cart-dropdown {
        width: 320px;
        right: -20px;
        left: auto;
    }
    
    .cart-actions {
        flex-direction: row;
        gap: 0.5rem;
    }
    
    .cart-btn {
        padding: 0.5rem 0.6rem;
        font-size: 0.8rem;
    }
    
    .cart-btn-outline {
        padding: 0.4rem 0.5rem;
    }
}

@media (max-width: 480px) {
    .cart-dropdown {
        width: 300px;
        right: -40px;
        left: auto;
    }
    
    /* Pastikan cart dropdown tidak keluar dari viewport */
    @media (max-width: 360px) {
        .cart-dropdown {
            width: 280px;
            right: -60px;
            left: auto;
        }
    }
    
    .cart-item {
        padding: 0.6rem;
        flex-wrap: nowrap;
    }
    
    .cart-item-img {
        width: 50px;
        height: 50px;
        margin-right: 0.8rem;
    }
    
    .cart-item-title {
        font-size: 0.8rem;
    }
    
    .cart-item-price {
        font-size: 0.8rem;
    }
    
    .cart-item-quantity {
        flex-wrap: wrap;
        gap: 0.3rem;
    }
    
    .quantity-btn {
        width: 22px;
        height: 22px;
        font-size: 0.7rem;
    }
    
    .quantity-input {
        width: 35px;
        margin: 0 0.3rem;
        font-size: 0.8rem;
    }
    
    .cart-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .cart-btn {
        padding: 0.6rem 0.8rem;
        font-size: 0.85rem;
        width: 100%;
    }
    
    .cart-btn-outline {
        padding: 0.5rem 0.7rem;
    }
}

/* Fix untuk viewport sangat kecil */
@media (max-width: 320px) {
    .cart-dropdown {
        width: 260px;
        right: -80px;
        left: auto;
    }
    
    .cart-header {
        padding: 0.8rem;
    }
    
    .cart-header h3 {
        font-size: 1rem;
    }
    
    .cart-footer {
        padding: 0.8rem;
    }
}

/* Tambahan untuk mencegah overflow horizontal */
.cart-dropdown * {
    box-sizing: border-box;
}

.cart-item-details {
    overflow: hidden;
}

/* Pastikan tombol tidak melebihi container */
.cart-actions {
    max-width: 100%;
}

.cart-btn {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}