/**
 * 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;
    /* Ensure proper touch targets for mobile */
    min-height: 44px;
    min-width: 44px;
    /* Prevent text selection on touch */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Improve touch responsiveness */
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
}

.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;
    }
}

/* Coupon Section */
.custom-mini-cart-coupon-section {
    margin: 15px 0;
    border-top: 1px solid #e9ecef;
    padding-top: 15px;
}

/* Applied Coupons */
.custom-mini-cart-applied-coupons {
    margin-bottom: 15px;
}

/* Hide empty coupon container */
.custom-mini-cart-applied-coupons:empty {
    display: none;
    margin-bottom: 0;
}

.custom-mini-cart-applied-coupons-title {
    font-size: 13px;
    font-weight: 600;
    color: #394A78;
    margin: 0 0 10px 0;
    font-family: 'PT Mono', monospace;
    text-transform: uppercase;
}

.custom-mini-cart-coupon-item {
    display: inline-flex;
    align-items: center;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 15px;
    padding: 4px 8px 4px 12px;
    margin-bottom: 8px;
    font-family: 'PT Mono', monospace;
    font-size: 12px;
    font-weight: 500;
    color: #333;
    gap: 6px;
    max-width: fit-content;
    height: 28px;
    box-sizing: border-box;
}

.custom-mini-cart-coupon-info {
    display: flex;
    align-items: center;
    gap: 0;
}

.custom-mini-cart-coupon-code {
    font-size: 12px;
    font-weight: 500;
    color: #333;
    font-family: 'PT Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1;
}

.custom-mini-cart-coupon-discount {
    display: none; /* Hide discount amount to match basket page */
}

.custom-mini-cart-coupon-promotion-note {
    display: none; /* Hide promotion note to match basket page */
}

/* Promotion Notice */
.custom-mini-cart-promotion-notice {
    background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
    border: 1px solid #4CAF50;
    border-radius: 8px;
    padding: 12px 15px;
    margin: 15px 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.custom-mini-cart-promotion-notice::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 2s infinite;
}

.custom-mini-cart-promotion-text {
    font-size: 13px;
    font-weight: 600;
    color: #2e7d32;
    font-family: 'PT Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.promotion-icon {
    margin-right: 8px;
    font-size: 14px;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.custom-mini-cart-coupon-remove {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 1px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 2px;
    flex-shrink: 0;
}

.custom-mini-cart-coupon-remove:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #666;
}

.custom-mini-cart-coupon-remove svg {
    width: 10px;
    height: 10px;
}

/* Coupon Toggle */
.custom-mini-cart-coupon-toggle-btn {
    background: none;
    border: none;
    color: #394A78;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-family: 'PT Mono', monospace;
    transition: color 0.2s ease;
}

.custom-mini-cart-coupon-toggle-btn:hover {
    color: #2c3a5f;
}

.custom-mini-cart-coupon-arrow {
    transition: transform 0.2s ease;
}

.custom-mini-cart-coupon-toggle-btn.expanded .custom-mini-cart-coupon-arrow {
    transform: rotate(180deg);
}

/* Coupon Input */
.custom-mini-cart-coupon-input-wrapper {
    margin-top: 10px;
}

.custom-mini-cart-coupon-input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.custom-mini-cart-coupon-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'PT Mono', monospace;
    background: #fff;
    transition: border-color 0.2s ease;
}

.custom-mini-cart-coupon-input:focus {
    outline: none;
    border-color: #394A78;
    box-shadow: 0 0 0 2px rgba(57, 74, 120, 0.1);
}

.custom-mini-cart-coupon-input::placeholder {
    color: #999;
    font-style: italic;
}

.custom-mini-cart-coupon-apply {
    background: #394A78;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'PT Mono', monospace;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-width: 60px;
}

.custom-mini-cart-coupon-apply:hover:not(:disabled) {
    background: #2c3a5f;
}

.custom-mini-cart-coupon-apply:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.custom-mini-cart-coupon-apply.loading {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Coupon Messages */
.custom-mini-cart-coupon-message {
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    margin-top: 8px;
}

.custom-mini-cart-coupon-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.custom-mini-cart-coupon-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.custom-mini-cart-coupon-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Coupon Message Links */
.custom-mini-cart-coupon-message a {
    color: #394A78;
    text-decoration: underline;
    font-weight: 600;
    transition: color 0.2s ease;
}

.custom-mini-cart-coupon-message a:hover {
    color: #2c3a5f;
    text-decoration: none;
}

/* Mobile Coupon Optimization */
@media (max-width: 480px) {
    .custom-mini-cart-coupon-input-group {
        flex-direction: column;
        gap: 8px;
    }
    
    .custom-mini-cart-coupon-apply {
        width: 100%;
        padding: 12px 16px;
    }
    
    .custom-mini-cart-coupon-item {
        padding: 10px 12px;
    }
    
    .custom-mini-cart-coupon-info {
        gap: 3px;
    }
}