/**
 * Products AJAX Animations & Loading States
 * Enhanced smooth transitions and loading indicators
 */

/* ===========================
   Loading States
   =========================== */

.products_wrapper__ {
    transition: opacity 0.3s ease-in-out;
    position: relative;
    min-height: 400px;
}

.products_wrapper__.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Loader Wrapper */
.loader_wrapper__ {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    transition: opacity 0.2s ease-in-out;
}

.loader_wrapper__.d-none {
    display: none !important;
}

/* Spinner Animation */
.loader {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin-loader 0.8s linear infinite;
}

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

/* ===========================
   Tab Buttons States
   =========================== */

.tab_button__ {
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
}

.tab_button__:hover {
    transform: translateY(-2px);
}

.tab_button__.active {
    position: relative;
}

.tab_button__.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 2px;
    background: currentColor;
    animation: slide-in 0.3s ease;
}

@keyframes slide-in {
    from {
        width: 0;
        opacity: 0;
    }
    to {
        width: 80%;
        opacity: 1;
    }
}

.tab_button__:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ===========================
   Product Card Animations
   =========================== */

.product_card__ {
    animation: fade-in-up 0.4s ease forwards;
    opacity: 0;
    transform: translateY(20px);
}

@keyframes fade-in-up {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation for multiple cards */
.product_card__:nth-child(1) { animation-delay: 0.05s; }
.product_card__:nth-child(2) { animation-delay: 0.1s; }
.product_card__:nth-child(3) { animation-delay: 0.15s; }
.product_card__:nth-child(4) { animation-delay: 0.2s; }
.product_card__:nth-child(5) { animation-delay: 0.25s; }
.product_card__:nth-child(6) { animation-delay: 0.3s; }
.product_card__:nth-child(7) { animation-delay: 0.35s; }
.product_card__:nth-child(8) { animation-delay: 0.4s; }

/* ===========================
   Error Messages
   =========================== */

.error-message-ajax {
    animation: shake 0.5s ease;
    border-radius: 8px;
    margin: 20px 0;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.error-message-ajax svg {
    color: #f39c12;
    animation: pulse 2s ease infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===========================
   Image Loading States
   =========================== */

.loading-omd {
    position: relative;
    background: #f5f5f5 !important;
    overflow: hidden;
}

.loading-omd::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin-omd 0.8s linear infinite;
    z-index: 10;
}

.loading-omd::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.8) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: shimmer 1.5s infinite;
}

@keyframes spin-omd {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

@keyframes shimmer {
    to {
        left: 100%;
    }
}

.loaded-omd::before,
.loaded-omd::after {
    display: none;
}

.loaded-omd img {
    animation: fade-in 0.3s ease;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===========================
   Retry Button
   =========================== */

.retry-button-ajax {
    min-width: 140px;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.retry-button-ajax:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.retry-button-ajax:active {
    transform: translateY(0);
}

/* ===========================
   Skeleton Loading (Alternative)
   =========================== */

.skeleton-card {
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.skeleton-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.8) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: shimmer 1.5s infinite;
}

.skeleton-text {
    height: 16px;
    background: #e0e0e0;
    border-radius: 4px;
    margin: 8px 0;
}

/* ===========================
   Responsive Adjustments
   =========================== */

@media (max-width: 768px) {
    .products_wrapper__ {
        min-height: 300px;
    }

    .loader {
        width: 36px;
        height: 36px;
    }

    .product_card__ {
        animation-delay: 0s !important;
    }

    .tab_button__.active::after {
        width: 90%;
    }
}

@media (max-width: 480px) {
    .products_wrapper__ {
        min-height: 200px;
    }

    .loader_wrapper__ {
        padding: 40px 20px;
    }

    .error-message-ajax {
        font-size: 14px;
    }
}

/* ===========================
   Accessibility
   =========================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===========================
   Print Styles
   =========================== */

@media print {
    .loader_wrapper__,
    .error-message-ajax,
    .tab_button__ {
        display: none !important;
    }

    .products_wrapper__ {
        opacity: 1 !important;
    }
}

/* ===========================
   Dark Mode Support
   =========================== */

/*@media (prefers-color-scheme: dark) {*/
/*    .loading-omd {*/
/*        background: #2c2c2c;*/
/*    }*/

/*    .loader {*/
/*        border-color: rgba(255, 255, 255, 0.1);*/
/*        border-top-color: #3498db;*/
/*    }*/

/*    .skeleton-card {*/
/*        background: #2c2c2c;*/
/*    }*/

/*    .skeleton-text {*/
/*        background: #3c3c3c;*/
/*    }*/
/*}*/

/* ===========================
   Focus States (Accessibility)
   =========================== */

.tab_button__:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.retry-button-ajax:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* ===========================
   Empty State
   =========================== */

.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: #666;
}

.empty-state svg {
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h4 {
    font-size: 20px;
    margin-bottom: 10px;
    color: #333;
}

.empty-state p {
    font-size: 14px;
    color: #999;
}
