/**
 * AutoHoist Tools - Frontend Styles
 *
 * @package AutoHoist_Tools
 */

/* Deferred Calculation Notice */
.autohoist-deferred-notice {
    padding: 12px 16px;
    background-color: #f8f9fa;
    border-left: 4px solid #007cba;
    margin-bottom: 16px;
    border-radius: 4px;
}

.autohoist-deferred-notice p {
    margin: 0;
    color: #333;
    font-size: 14px;
}

/* Loading Overlay */
#autohoist-loading {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.98);
    padding: 20px 32px;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

#autohoist-loading span {
    display: flex;
    align-items: center;
    gap: 12px;
}

#autohoist-loading .spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: #007cba;
    border-radius: 50%;
    animation: autohoist-spin 0.8s linear infinite;
}

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

/* Cart Optimization Overlay - prevents interaction during updates */
.autohoist-cart-updating {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.autohoist-cart-updating::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.5);
    z-index: 100;
}

/* Calculate Shipping Button */
.autohoist-calculate-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #007cba;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.autohoist-calculate-btn:hover {
    background: #005a87;
}

.autohoist-calculate-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.autohoist-calculate-btn .spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: autohoist-spin 0.8s linear infinite;
}

.autohoist-calculate-btn.loading .spinner {
    display: inline-block;
}

.autohoist-calculate-btn.loading .btn-text {
    opacity: 0.7;
}

/* Shipping Info Notice */
.autohoist-shipping-info {
    padding: 12px 16px;
    background: #e8f4fc;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #0073aa;
}

.autohoist-shipping-info p {
    margin: 0;
}

.autohoist-shipping-info strong {
    font-weight: 600;
}

/* Cached Rate Indicator */
.autohoist-cached-indicator {
    display: inline-block;
    padding: 2px 8px;
    background: #d4edda;
    color: #155724;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 3px;
    margin-left: 8px;
    vertical-align: middle;
}

/* Performance Status */
.autohoist-perf-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 9999;
    display: none;
}

.autohoist-perf-status.visible {
    display: block;
}

/* Shipping Method Optimization */
.woocommerce-shipping-methods .autohoist-optimized {
    position: relative;
}

.woocommerce-shipping-methods .autohoist-optimized::before {
    content: '⚡';
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
}

/* Cart Update Fast Mode */
.woocommerce-cart .cart_totals.autohoist-fast-mode {
    transition: opacity 0.15s ease;
}

.woocommerce-cart .cart_totals.autohoist-fast-mode.updating {
    opacity: 0.6;
}

/* Block Element Modifier - Processing state */
.autohoist-processing {
    position: relative;
}

.autohoist-processing::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
}

.autohoist-processing::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid #e0e0e0;
    border-top-color: #007cba;
    border-radius: 50%;
    animation: autohoist-spin 0.8s linear infinite;
    z-index: 11;
}

/* Success Animation */
@keyframes autohoist-success {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.autohoist-success-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #28a745;
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    animation: autohoist-success 0.3s ease-out;
}

/* Responsive */
@media (max-width: 768px) {
    #autohoist-loading {
        padding: 16px 24px;
        font-size: 13px;
    }
    
    .autohoist-calculate-btn {
        width: 100%;
        justify-content: center;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .autohoist-deferred-notice {
        border-left-width: 6px;
    }
    
    #autohoist-loading {
        border: 2px solid #000;
    }
    
    .autohoist-calculate-btn {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    #autohoist-loading .spinner,
    .autohoist-calculate-btn .spinner,
    .autohoist-processing::after {
        animation: none;
    }
    
    .autohoist-success-indicator {
        animation: none;
    }
}

/* Print styles - hide optimization UI */
@media print {
    #autohoist-loading,
    .autohoist-deferred-notice,
    .autohoist-calculate-btn,
    .autohoist-perf-status {
        display: none !important;
    }
}
