/* Enhanced HTMX Styles for Zamel Product Pages */

/* Container setup for HTMX content */
#product-container {
    position: relative !important;
    min-height: 200px;
}

/* Enhanced Loading States with Fade Effects */
.htmx-indicator {
    display: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 400ms ease-in-out, visibility 400ms ease-in-out;
    will-change: opacity, visibility;
}

.htmx-request .htmx-indicator {
    display: flex !important;
    opacity: 1;
    visibility: visible;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    animation: fadeInScale 400ms ease-out;
}

@keyframes fadeInScale {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Main Loading Container */
.zamel-loading-container {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 9999 !important;
    background: rgba(255, 255, 255, 0.95) !important;
    padding: 2rem !important;
    border-radius: 16px !important;
    min-width: 280px !important;
    text-align: center !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2) !important;
}

.zamel-loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* Enhanced Spinner with Ring Effect */
.zamel-spinner-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zamel-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(229, 62, 62, 0.2);
    border-top: 3px solid #e53e3e;
    border-radius: 50%;
    animation: zamel-spin 1s linear infinite;
}

.zamel-spinner-ring {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 2px solid rgba(229, 62, 62, 0.2);
    border-radius: 50%;
    animation: zamel-ring-pulse 2s ease-in-out infinite;
}

@keyframes zamel-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes zamel-ring-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.5;
    }
}

/* Loading Text with Animation */
.zamel-loading-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #2d3748;
    font-weight: 600;
}

.zamel-loading-message {
    font-size: 1.1rem;
}

/* Animated Loading Dots */
.zamel-loading-dots {
    display: flex;
    gap: 2px;
}

.zamel-dot {
    font-weight: bold;
    animation: zamel-dot-bounce 1.5s ease-in-out infinite;
}

.zamel-dot-1 {
    animation-delay: 0s;
}

.zamel-dot-2 {
    animation-delay: 0.2s;
}

.zamel-dot-3 {
    animation-delay: 0.4s;
}

@keyframes zamel-dot-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Progress Bar */
.zamel-progress-bar {
    width: 200px;
    height: 3px;
    background: rgba(229, 62, 62, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.zamel-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #e53e3e, #ff6b6b);
    animation: zamel-progress 2s ease-in-out infinite;
}

@keyframes zamel-progress {
    0% {
        width: 0%;
        margin-left: 0%;
    }
    50% {
        width: 75%;
        margin-left: 0%;
    }
    100% {
        width: 0%;
        margin-left: 100%;
    }
}

/* Action Description */
.zamel-loading-action {
    font-size: 0.9rem;
    color: #718096;
    min-height: 1.2rem;
}

.zamel-loading-action [data-loading-action] {
    display: none;
}

.zamel-loading-action [data-loading-action].active {
    display: inline;
}

/* Minimal Loading Indicator */
.zamel-loading-minimal {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    z-index: 9998 !important;
    background: rgba(229, 62, 62, 0.9) !important;
    color: white !important;
    padding: 0.75rem 1rem !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    font-size: 0.9rem !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.zamel-spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: zamel-spin 1s linear infinite;
}

/* Full Screen Loading Overlay */
.zamel-loading-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 9999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.zamel-overlay-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
}

.zamel-overlay-content {
    position: relative;
    background: white;
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.zamel-spinner-large {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(229, 62, 62, 0.2);
    border-top: 4px solid #e53e3e;
    border-radius: 50%;
    animation: zamel-spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

.zamel-overlay-title {
    margin: 0 0 0.5rem;
    color: #2d3748;
    font-size: 1.5rem;
}

.zamel-overlay-message {
    margin: 0;
    color: #718096;
    font-size: 1rem;
}

/* Enhanced Product Grid Loading States */
body.htmx-request #products-grid > *,
.htmx-request #products-grid > *,
#products-grid.htmx-request > * {
    transition: opacity 300ms ease-out, filter 300ms ease-out !important;
    opacity: 0.4 !important;
    filter: blur(1px) grayscale(0.3) !important;
    will-change: opacity, filter;
}

/* Loading Pulse Animation for Form Elements */
.htmx-request select[hx-get],
.htmx-request input[type="text"] {
    background: linear-gradient(90deg,
    rgba(229, 62, 62, 0.05) 0%,
    rgba(229, 62, 62, 0.1) 50%,
    rgba(229, 62, 62, 0.05) 100%);
    background-size: 200% 100%;
    animation: zamel-input-loading 2s ease-in-out infinite;
}

@keyframes zamel-input-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Global Body Loading States - Removed global fade, keep only for indicators */

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .htmx-request .htmx-indicator {
        background: rgba(30, 30, 30, 0.95);
        color: #ffffff;
        border-color: rgba(229, 62, 62, 0.3);
    }

    .zamel-loading-container {
        background: rgba(30, 30, 30, 0.95);
        color: #ffffff;
    }

    .zamel-loading-text {
        color: #e2e8f0;
    }

    .zamel-loading-action {
        color: #a0aec0;
    }

    .zamel-loading-minimal {
        background: rgba(229, 62, 62, 0.15);
        border-color: rgba(229, 62, 62, 0.3);
    }

    .zamel-overlay-content {
        background: #1a1a1a;
        color: #ffffff;
    }

    .zamel-overlay-title {
        color: #e2e8f0;
    }

    .zamel-overlay-message {
        color: #a0aec0;
    }
}

/* Price calculation visual indicators */
.zamel-price-calculated {
    font-weight: bold !important;
    color: #e53e3e !important;
}

/* Disable HTMX for no-js environments */
.no-js .htmx-indicator,
.no-js [hx-get],
.no-js [hx-post] {
    display: none !important;
}

/* HTMX error states */
.htmx-error {
    background-color: #fed7d7;
    border: 1px solid #feb2b2;
    color: #c53030;
    padding: 1rem;
    border-radius: 6px;
    margin: 1rem 0;
}

/* ETIM Range Slider Styles - Zamel Brand Color */
.etim-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.etim-range:hover {
    opacity: 1;
}

.etim-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #DE000E;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(222, 0, 14, 0.3);
}

.etim-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #DE000E;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(222, 0, 14, 0.3);
}

.etim-range::-webkit-slider-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: linear-gradient(to right, #DE000E 0%, #DE000E 50%, #e2e8f0 50%, #e2e8f0 100%);
    border-radius: 3px;
}

.etim-range::-moz-range-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: #e2e8f0;
    border-radius: 3px;
}

.etim-range:focus {
    outline: none;
}

.etim-range:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px rgba(222, 0, 14, 0.2);
}

.etim-range:focus::-moz-range-thumb {
    box-shadow: 0 0 0 3px rgba(222, 0, 14, 0.2);
}

