/**
 * Custom Mini Cart Block Styling
 */

/* Wrapper and alignment */
.custom-mini-cart-wrapper {
    position: relative;
    display: inline-block;
}

.custom-mini-cart-wrapper.alignment-left {
    text-align: left;
}

.custom-mini-cart-wrapper.alignment-center {
    text-align: center;
}

.custom-mini-cart-wrapper.alignment-right {
    text-align: right;
}

/* Cart Button */
.custom-mini-cart-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.3s ease;
    color: inherit;
    font-size: 16px;
    position: relative;
}

.custom-mini-cart-button:hover {
    background: rgba(0, 0, 0, 0.05);
}

.custom-mini-cart-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

/* Custom cart icon image styles */
.custom-mini-cart-icon .custom-cart-icon-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    display: block;
}

.custom-mini-cart-icon svg {
    width: 100%;
    height: 100%;
}

.custom-mini-cart-text {
    font-weight: 500;
}

.custom-mini-cart-total {
    font-weight: normal;
    font-size: 14px;
    color: inherit;
}

.custom-mini-cart-count {
    position: absolute;
    top: -3px;
    right: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #FF0000;
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    padding: 2px 6px;
    z-index: 10;
    transform: translateX(50%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.custom-mini-cart-count[data-count="0"] {
    display: none;
}

.custom-mini-cart-count-text:empty {
    display: none;
}

/* Cart Drawer */
.custom-mini-cart-drawer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000100; /* Well above sticky header (1000) */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
}

.custom-mini-cart-drawer.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.custom-mini-cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
    z-index: 1000100; /* Same as drawer container */
}

.custom-mini-cart-content {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 400px;
    height: 100%;
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    z-index: 1000101; /* Above overlay */
}

.custom-mini-cart-drawer.is-open .custom-mini-cart-content {
    transform: translateX(0);
}

/* Header */
.custom-mini-cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.custom-mini-cart-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.custom-mini-cart-count-text {
    color: #666;
    font-weight: normal;
}

.custom-mini-cart-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    color: #666;
    transition: all 0.2s ease;
}

.custom-mini-cart-close:hover {
    background: #f5f5f5;
    color: #333;
}

/* Cart Items */
.custom-mini-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.custom-mini-cart-empty {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.custom-mini-cart-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f5f5f5;
    position: relative;
    transition: opacity 0.3s ease;
}

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

.custom-mini-cart-item.updating,
.custom-mini-cart-item.removing {
    opacity: 0.6;
    pointer-events: none;
}

.custom-mini-cart-item-image {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: 4px;
    overflow: hidden;
}

.custom-mini-cart-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.custom-mini-cart-item-details {
    flex: 1;
    min-width: 0;
}

.custom-mini-cart-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 8px;
}

.custom-mini-cart-item-name {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    color: #EB540D;
    line-height: 1.3;
    text-align: left;
    flex: 1;
}

.custom-mini-cart-item-name a {
    color: inherit;
    text-decoration: none;
}

.custom-mini-cart-item-name a:hover {
    color: #007cba;
}

.custom-mini-cart-item-price-quantity {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.custom-mini-cart-item-quantity {
    display: flex;
    align-items: center;
    gap: 0;
    background: #f8f9fa;
    border: 2px solid #99C3B9;
    border-radius: 4px;
    padding: 0;
}

.custom-mini-cart-item-quantity button {
    background: white;
    border: none;
    border-radius: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
    padding: 0;
    margin: 0;
}

.custom-mini-cart-item-quantity button:hover:not(:disabled) {
    background: #f0f0f0;
}

.custom-mini-cart-item-quantity button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.quantity-input {
    font-size: 13px;
    font-weight: 500;
    min-width: 40px;
    width: 40px;
    height: 28px;
    text-align: center;
    border: none;
    border-radius: 0;
    padding: 0;
    background: white;
    -moz-appearance: textfield; /* Firefox */
}

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

.quantity-input:focus {
    outline: 2px solid #007cba;
    outline-offset: 1px;
}

.custom-mini-cart-item-total {
    font-weight: normal;
    color: #333;
    font-size: 1rem;
}

.custom-mini-cart-item-remove {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 3px;
    color: #999;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-top: -2px; /* Slight adjustment for alignment */
}

.custom-mini-cart-item-remove:hover {
    background: #ffebee;
    color: #d32f2f;
}

.custom-mini-cart-item-remove:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Footer */
.custom-mini-cart-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.custom-mini-cart-subtotal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 16px;
    font-weight: 600;
}

.custom-mini-cart-subtotal-label {
    color: #333;
}

.custom-mini-cart-subtotal-amount {
    color: #333;
}

/* Minimum Order Notice */
.custom-mini-cart-minimum-notice {
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 12px 15px;
    margin: 16px 0;
    text-align: center;
}

.custom-mini-cart-minimum-text {
    color: #856404;
    font-size: 13px;
    font-weight: 500;
    margin: 0 0 10px 0;
    line-height: 1.4;
}

.custom-mini-cart-progress {
    background: #f8f9fa;
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
    position: relative;
}

.custom-mini-cart-progress-bar {
    background: #81C784;
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

/* Free Shipping Notice */
.custom-mini-cart-shipping-notice {
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 12px 15px;
    margin: 15px 0;
    text-align: center;
}

.custom-mini-cart-shipping-notice.shipping-achieved {
    background: transparent;
    border: none;
}

.custom-mini-cart-shipping-text {
    color: #155724;
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 10px 0;
    line-height: 1.4;
}

.custom-mini-cart-shipping-notice.shipping-achieved .custom-mini-cart-shipping-text {
    margin-bottom: 0;
}

.custom-mini-cart-shipping-progress {
    background: #f8f9fa;
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
    position: relative;
}

.custom-mini-cart-shipping-progress-bar {
    background: #4C62A9;
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

/* Action Buttons */
.custom-mini-cart-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.custom-mini-cart-view-cart,
.custom-mini-cart-checkout {
    flex: 1;
    padding: 12px 16px;
    border-radius: 0;
    text-decoration: none;
    text-align: center;
    font-weight: 500;
    font-size: 14px;
    font-family: 'PT Mono', monospace;
    text-transform: uppercase;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    display: block;
}

.custom-mini-cart-view-cart {
    background: #f8f9fa;
    color: #394A78;
    border: 1px solid #394A78;
}

.custom-mini-cart-view-cart:hover {
    background: #e9ecef;
    border-color: #394A78;
    color: #394A78;
    text-decoration: none;
}

.custom-mini-cart-checkout {
    background: #99C3B9;
    color: #394A78;
}

.custom-mini-cart-checkout:hover:not(.disabled) {
    background: #7EB1A6;
    color: #394A78;
    text-decoration: none;
}

.custom-mini-cart-checkout.disabled {
    background: #e0e0e0 !important;
    color: #999 !important;
    cursor: not-allowed !important;
    opacity: 0.6;
    pointer-events: none;
}

.custom-mini-cart-shipping-notice {
    font-size: 12px;
    color: #666;
    margin: 0;
    text-align: center;
    line-height: 1.4;
}

/* Body class when cart is open */
body.custom-mini-cart-open {
    overflow: hidden;
}

/* Mini cart always renders at body level - no special sticky header handling needed */

/* Mobile Responsive */
@media (max-width: 768px) {
    .custom-mini-cart-content {
        width: 90%;
        max-width: 380px;
        min-width: 280px;
    }
    
    .custom-mini-cart-header {
        padding: 16px;
    }
    
    .custom-mini-cart-items {
        padding: 16px;
    }
    
    .custom-mini-cart-footer {
        padding: 16px;
    }
    
    .custom-mini-cart-item {
        gap: 10px;
    }
    
    .custom-mini-cart-item-image {
        width: 54px;
        height: 54px;
    }
    
    .custom-mini-cart-item-header {
        gap: 6px;
    }
    
    .custom-mini-cart-item-name {
        font-size: 1rem;
    }
    
    .custom-mini-cart-actions {
        flex-direction: column;
    }
    
    .custom-mini-cart-minimum-notice {
        padding: 10px 12px;
        margin: 12px 0;
    }
    
    .custom-mini-cart-minimum-text {
        font-size: 12px;
    }
    
    /* Hide price text on mobile for cleaner header */
    .custom-mini-cart-total {
        display: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .custom-mini-cart-button:hover {
        background: rgba(0, 0, 0, 0.1);
    }
    
    .custom-mini-cart-overlay {
        background: rgba(0, 0, 0, 0.8);
    }
    
    .custom-mini-cart-item {
        border-bottom-color: #ccc;
    }
}