/**
 * Free Delivery Indicator - Modern Frontend Styles
 * Version: 1.1.0
 */

/* CSS Variables for easy customization */
:root {
    --fdi-primary-color: #10b981;
    --fdi-success-color: #059669;
    --fdi-warning-color: #f59e0b;
    --fdi-background: #ffffff;
    --fdi-text-primary: #111827;
    --fdi-text-secondary: #6b7280;
    --fdi-border-color: #e5e7eb;
    --fdi-progress-bg: #e5e7eb;
    --fdi-progress-fill: #10b981;
    --fdi-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --fdi-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --fdi-radius: 0.75rem;
}

/* Main indicator container */
.fdi-indicator {
    margin: 1rem 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Threshold blocks - Modern card design */
.fdi-threshold-block {
    background: var(--fdi-background);
    border: 1px solid var(--fdi-border-color);
    border-radius: var(--fdi-radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--fdi-shadow-sm);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.fdi-threshold-block:hover {
    box-shadow: var(--fdi-shadow-md);
    transform: translateY(-2px);
}

.fdi-threshold-block:last-child {
    margin-bottom: 0;
}

/* Success state with subtle gradient */
.fdi-threshold-block.fdi-qualified {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-color: var(--fdi-success-color);
}

/* Express delivery card accent */
.fdi-express {
    border-left: 3px solid var(--fdi-warning-color);
}

/* Message container */
.fdi-message {
    display: flex;
    align-items: center;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--fdi-text-primary);
    line-height: 1.5;
}

/* Modern icon styles */
.fdi-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    margin-right: 0.5rem;
    background: var(--fdi-success-color);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: bold;
    animation: checkBounce 0.5s ease;
}

@keyframes checkBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Text */
.fdi-text {
    flex: 1;
    color: var(--fdi-text-primary);
}

/* Amount badge styling */
.fdi-amount {
    font-weight: 600;
    color: var(--fdi-primary-color);
}

/* Modern progress bar */
.fdi-progress-bar {
    margin-top: 0.75rem;
    height: 0.375rem;
    background: var(--fdi-progress-bg);
    border-radius: 9999px;
    overflow: hidden;
    position: relative;
}

.fdi-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--fdi-progress-fill), var(--fdi-success-color));
    border-radius: 9999px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Mini cart specific styles */
.fdi-minicart-wrapper {
    padding: 0.75rem 0;
    margin: 0.75rem 0;
    border-top: 1px solid var(--fdi-border-color);
}

.widget_shopping_cart .fdi-minicart-wrapper {
    margin: 0.75rem -1.25rem;
    padding: 0.75rem 1.25rem;
}

.fdi-minicart-wrapper .fdi-threshold-block {
    margin-bottom: 0;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1px solid #bbf7d0;
}

.fdi-minicart-wrapper .fdi-message {
    font-size: 0.875rem;
}

.fdi-minicart-wrapper .fdi-progress-bar {
    height: 0.25rem;
    margin-top: 0.5rem;
}

/* Block-based mini cart compatibility */
.wp-block-woocommerce-mini-cart-contents .fdi-minicart-wrapper {
    margin: 1rem;
    padding: 1rem;
    background: var(--fdi-background);
    border-radius: var(--fdi-radius);
    border: 1px solid var(--fdi-border-color);
    box-shadow: var(--fdi-shadow-sm);
}

.wc-block-mini-cart__footer .fdi-minicart-wrapper {
    order: -1;
    width: 100%;
}

/* Responsive styles - Mobile first approach */
@media (max-width: 640px) {
    .fdi-threshold-block {
        padding: 0.875rem;
        border-radius: 0.625rem;
    }
    
    .fdi-message {
        font-size: 0.875rem;
    }
    
    .fdi-icon {
        width: 1.25rem;
        height: 1.25rem;
        font-size: 0.625rem;
    }
    
    .fdi-progress-bar {
        height: 0.25rem;
    }
}

/* Tablet and up */
@media (min-width: 641px) {
    .fdi-indicator {
        max-width: 100%;
    }
    
    .fdi-threshold-block {
        padding: 1.125rem 1.25rem;
    }
}

/* Cart page specific - Clean card design */
.woocommerce-cart .fdi-indicator {
    background: var(--fdi-background);
    padding: 1.5rem;
    border-radius: var(--fdi-radius);
    margin-bottom: 1.5rem;
    border: 1px solid var(--fdi-border-color);
    box-shadow: var(--fdi-shadow-sm);
}

.woocommerce-cart .fdi-threshold-block {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #fbbf24;
    margin-bottom: 1rem;
}

/* Checkout page specific */
.woocommerce-checkout .fdi-indicator {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #fefce8;
    border: 1px solid #fef08a;
    border-radius: var(--fdi-radius);
}

/* Widget area */
.widget .fdi-indicator {
    margin: 0.75rem 0;
}

.widget .fdi-threshold-block {
    padding: 0.625rem 0.75rem;
    font-size: 0.8125rem;
}

.widget .fdi-message {
    font-size: 0.8125rem;
}

.widget .fdi-progress-bar {
    height: 0.1875rem;
    margin-top: 0.375rem;
}

/* Animation for value updates */
.fdi-updating {
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

/* Loading state - Modern spinner */
.fdi-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.fdi-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1.25rem;
    height: 1.25rem;
    margin: -0.625rem 0 0 -0.625rem;
    border: 2px solid var(--fdi-border-color);
    border-top-color: var(--fdi-primary-color);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Accessibility improvements */
.fdi-indicator:focus-within {
    outline: 2px solid var(--fdi-primary-color);
    outline-offset: 2px;
}

.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --fdi-background: #1f2937;
        --fdi-text-primary: #f3f4f6;
        --fdi-text-secondary: #9ca3af;
        --fdi-border-color: #374151;
        --fdi-progress-bg: #374151;
    }
    
    .fdi-threshold-block {
        background: var(--fdi-background);
    }
    
    .fdi-threshold-block.fdi-qualified {
        background: linear-gradient(135deg, #064e3b 0%, #065f46 100%);
    }
    
    .woocommerce-cart .fdi-threshold-block {
        background: linear-gradient(135deg, #451a03 0%, #78350f 100%);
    }
}

/* Print styles */
@media print {
    .fdi-indicator {
        display: none;
    }
}

/* Popular theme compatibility */
/* Flatsome theme */
.flatsome .fdi-indicator {
    margin: 0.75rem 0;
}

/* Astra theme */
.ast-woocommerce-cart-menu .fdi-minicart-wrapper {
    padding: 0.75rem;
}

/* OceanWP theme */
.oceanwp-theme .fdi-minicart-wrapper {
    margin: 0.75rem 0;
}

/* Storefront theme */
.storefront-theme .fdi-indicator {
    margin: 1rem 0;
}

/* RTL support */
.rtl .fdi-icon {
    margin-right: 0;
    margin-left: 0.5rem;
}

.rtl .fdi-express {
    border-left: none;
    border-right: 3px solid var(--fdi-warning-color);
}

/* Smooth transitions for all interactive elements */
* {
    transition-property: none;
}

.fdi-threshold-block,
.fdi-progress-fill,
.fdi-icon,
.fdi-updating {
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
}

/* Unified display mode styles */
.fdi-unified .fdi-unified-block {
    padding: 1.125rem;
}

.fdi-unified .fdi-secondary-message {
    margin-top: 0.625rem;
    padding-top: 0.625rem;
    border-top: 1px solid var(--fdi-border-color);
    font-size: 0.875rem;
    color: var(--fdi-text-secondary);
}

.fdi-unified .fdi-text-secondary {
    color: var(--fdi-text-secondary);
    font-size: 0.875rem;
}

.fdi-unified .fdi-amount-secondary {
    font-weight: 600;
    color: var(--fdi-warning-color);
}

/* Unified block qualified state */
.fdi-unified .fdi-unified-block.fdi-qualified {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border-color: var(--fdi-success-color);
}

.fdi-unified .fdi-unified-block.fdi-qualified .fdi-secondary-message {
    border-top-color: rgba(5, 150, 105, 0.2);
}

/* Mobile optimizations for unified display */
@media (max-width: 640px) {
    .fdi-unified .fdi-secondary-message {
        font-size: 0.8125rem;
    }
    
    .fdi-unified .fdi-unified-block {
        padding: 0.875rem;
    }
}

/* Cart page unified display */
.woocommerce-cart .fdi-unified .fdi-unified-block {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #fbbf24;
}

/* Mini cart unified display */
.fdi-minicart-wrapper .fdi-unified .fdi-unified-block {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1px solid #bbf7d0;
}