/* Reset and Base Styles */
.custom-add-to-cart * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Add to Cart Container */
.custom-add-to-cart {
    margin: 15px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.variation-dropdowns {
    margin-bottom: 15px;
}

.variation-dropdown {
    margin-bottom: 15px;
}

.variation-dropdown label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
    color: #333;
}

.variation-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.variation-select:focus {
    outline: none;
    border-color: #666;
}

.variation-select option {
    padding: 8px;
}

.variation-select option:disabled {
    color: #999;
    font-style: italic;
    background-color: #f8f8f8;
}

.variation-select option[data-partial-out-of-stock="true"] {
    color: #ff9800;
    font-style: italic;
}

.variation-price-display {
    margin: 15px 0;
    padding: 10px;
    background: #f8f8f8;
    border-radius: 4px;
    border-left: 3px solid #4CAF50;
    display: none;
}

.variation-price-display .price-label {
    font-weight: 600;
    color: #333;
    margin-right: 5px;
}

.variation-price-display .selected-price {
    font-size: 18px;
    font-weight: 700;
    color: #000;
}

.custom-add-to-cart-footer {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    position: relative;
    align-items: center;
}

.variation-error {
    position: absolute;
    top: -25px;
    left: 0;
    color: #e00;
    font-size: 12px;
    font-weight: 500;
    background: #ffe6e6;
    padding: 4px 8px;
    border-radius: 3px;
    border: 1px solid #ffcccc;
    display: none;
}

.custom-quantity {
    width: 70px !important;
    padding: 0 10px !important;
    border: 1px solid #ddd !important;
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
    height: 50px;
    box-sizing: border-box;
}

.button-group {
    display: flex;
    flex: 1;
    gap: 8px;
}

.custom-add-to-cart-button,
.custom-buy-now-button {
    flex: 1;
    padding: 0 10px;
    height: 50px;
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 700;
    border: none;
    text-align: center;
    position: relative;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.custom-add-to-cart-button {
    background: #4CAF50;
}

.custom-buy-now-button {
    background: #2196F3;
}

.custom-add-to-cart-button:hover {
    background: #45a049;
}

.custom-buy-now-button:hover {
    background: #0b7dda;
}

.custom-add-to-cart-button:disabled,
.custom-buy-now-button:disabled {
    background: #999;
    cursor: not-allowed;
}

/* Button states (ONLY for Add to Cart button) */
.custom-add-to-cart-button.loading {
    color: transparent !important;
}

.custom-add-to-cart-button.success {
    background-color: #4CAF50 !important;
    color: #fff !important;
}

/* Buy Now button should NOT have loading/success states */
.custom-buy-now-button.loading,
.custom-buy-now-button.success {
    color: #fff !important;
    background-color: #2196F3 !important;
}

.custom-buy-now-button.loading .spinner,
.custom-buy-now-button.success .checkmark {
    display: none;
}

.spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

.spinner.small {
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border-width: 2px;
}

.checkmark {
    position: relative;
    display: inline-block;
    margin-right: 8px;
    font-size: 18px;
    font-weight: bold;
    opacity: 1;
    transition: opacity 0.3s;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Mini Cart Icon */
.custom-mini-cart-icon {
    position: relative;
    display: inline-block;
    cursor: pointer;
    margin-left: 15px;
    margin-top: 12px;
}

.cart-count {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #f00;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

.custom-mini-cart-icon svg {
    width: 24px;
    height: 24px;
}

/* Cart Panel */
.custom-cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 9998;
    display: none;
}

.custom-cart-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 100%;
    max-width: 350px;
    height: 100%;
    background: #fff;
    z-index: 9999;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -3px 0 15px rgba(0,0,0,0.1);
}

.custom-cart-panel.open {
    right: 0;
}

.custom-cart-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafafa;
}

.custom-cart-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.close-cart {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
    color: #777;
}

.close-cart:hover {
    color: #000;
}

.custom-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    max-height: calc(100vh - 300px);
}

/* Cart Item Improvements */
.cart-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid #f5f5f5;
    position: relative;
    transition: opacity 0.3s;
    background-color: #f3f3f3;
    border-radius: 7px;
    margin: 10px auto;
    align-items: flex-start;
}

.cart-item.removing {
    opacity: 0;
}

.item-thumbnail img {
    width: 60px;
    height: 60px;
    border-radius: 4px;
    object-fit: cover;
}

.item-details {
    flex: 1;
    padding-right: 80px;
    min-width: 0;
    position: relative;
}

.item-title {
    font-weight: 600;
    text-decoration: none;
    color: #333 !important;
    display: block;
    margin-bottom: 5px;
    font-size: 14px !important;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.item-title:hover {
    color: #000;
}

.item-variation {
    font-size: 12px;
    color: #666;
    margin-bottom: 3px;
    line-height: 1.3;
}

/* Variations on one line */
.item-variation .variation-item {
    display: inline;
    margin-right: 10px;
}

.item-variation .variation-item:not(:last-child):after {
    content: " | ";
    color: #999;
    margin-left: 5px;
}

.item-quantity {
    font-size: 14px;
    color: #444;
    font-weight: 500;
    margin-top: 3px;
}

/* Quantity Controls - Minimal Round Design */
.item-quantity-controls {
    position: absolute;
    bottom: 5px;
    right: 5px;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 2;
}

.quantity-selector-compact {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.quantity-minus-compact,
.quantity-plus-compact {
    width: 24px;
    height: 24px;
    border: none;
    background: #f5f5f5;
    color: #333;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.quantity-minus-compact:hover,
.quantity-plus-compact:hover {
    background: #e0e0e0;
}

.quantity-minus-compact {
    border-right: 1px solid #ddd;
}

.quantity-plus-compact {
    border-left: 1px solid #ddd;
}

.item-quantity-input-compact {
    width: 30px;
    height: 24px;
    border: none;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    background: #fff;
    padding: 0;
    -moz-appearance: textfield;
}

.item-quantity-input-compact::-webkit-outer-spin-button,
.item-quantity-input-compact::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.item-remove {
    position: absolute;
    top: 5px;
    right: 4px;
    z-index: 3;
}

.remove-item {
    background: #c5d5c9;
    border: none;
    cursor: pointer;
    padding: 5px;
    opacity: 0.7;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

.remove-item:hover {
    opacity: 1;
    background: #ff6b6b;
}

.remove-item svg {
    width: 16px;
    height: 16px;
    stroke: #1c1b1b;
}

.remove-item:hover svg {
    stroke: #fff;
}

.empty-cart, .loading-cart {
    text-align: center;
    padding: 50px 15px;
    color: #777;
    font-size: 14px;
}

.loading-cart {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Cart Summary Section */
.cart-summary {
    padding: 15px;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.summary-row.total {
    font-weight: 600;
    font-size: 16px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
}

.summary-label {
    color: #666;
}

.summary-value {
    font-weight: 500;
    color: #333;
}

/* Free Shipping Progress Bar */
.free-shipping-progress {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.progress-container {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    margin: 8px 0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: #4CAF50;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.free-shipping-message {
    font-size: 12px;
    color: #666;
    text-align: center;
    margin-top: 5px;
}

.free-shipping-message .amount-needed {
    font-weight: 600;
    color: #2196F3;
}

.free-shipping-message.success {
    color: #4CAF50;
    font-weight: 500;
}

.custom-cart-footer {
    padding: 15px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    border-top: 1px solid #eee;
    background: #fafafa;
}

.cart-button, .checkout-button {
    display: block;
    text-align: center;
    padding: 12px;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s;
}

.cart-button {
    background: #fff;
    color: #333;
    border: 1px solid #ddd;
}

.cart-button:hover {
    background: #f5f5f5;
}

.checkout-button {
    background: #000;
    color: #fff;
    border: 1px solid #000;
}

.checkout-button:hover {
    background: #333;
}

/* Responsive */
@media (max-width: 480px) {
    .custom-cart-panel {
        max-width: 100%;
    }
    
    .custom-cart-footer {
        grid-template-columns: 1fr;
    }
    
    .custom-add-to-cart-footer {
        flex-direction: column;
        align-items: stretch;
    }
    
    .custom-quantity {
        width: 100%;
    }
    
    .item-title {
        max-width: 150px;
    }
    
    .item-details {
        padding-right: 70px;
    }
    
    .quantity-selector-compact {
        transform: scale(0.9);
        transform-origin: right bottom;
    }
}