/* Global loading overlay and skeletons */
:root {
    --loading-backdrop: rgba(0, 0, 0, 0.35);
    --loading-card-bg: #ffffff;
    --loading-text: var(--text-dark, #1a1a1a);
    --loading-sub: var(--text-light, #777);
    --loading-spinner: var(--primary-red, #d32f2f);
}

#globalLoadingOverlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--loading-backdrop);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 12000;
}

#globalLoadingOverlay.active {
    display: flex;
    animation: loading-fade-in 160ms ease-out;
}

.loading-card {
    min-width: 240px;
    max-width: 340px;
    padding: 20px 22px;
    border-radius: 18px;
    background: var(--loading-card-bg);
    color: var(--loading-text);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transform: scale(0.98);
    animation: loading-pop 200ms ease-out forwards;
}

.loading-spinner {
    display: none;
}

.loading-copy {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    text-align: center;
}

.loading-brand {
    font-family: "Cairo", "Tajawal", "Noto Kufi Arabic", "Segoe UI", sans-serif;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    background: linear-gradient(0deg, #7f1d1d 0%, #b91c1c 35%, #ef4444 60%, transparent 62%, transparent 100%);
    background-size: 100% 220%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    position: relative;
    animation: loading-liquid-fill 6.2s ease-in-out infinite, loading-liquid-shimmer 2.8s linear infinite;
}

.loading-text {
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--loading-text);
    text-align: center;
}

.loading-subtext {
    color: var(--loading-sub);
    font-size: 13px;
    text-align: center;
}

/* Skeletons */
.skeleton-block {
    position: relative;
    overflow: hidden;
    background: linear-gradient(90deg, #f3f3f3 0%, #e9e9e9 50%, #f3f3f3 100%);
    background-size: 200% 100%;
    animation: loading-shimmer 1.1s ease-in-out infinite;
    border-radius: 10px;
}

.skeleton-line {
    height: 12px;
    margin-bottom: 8px;
}

.skeleton-thumb {
    width: 100%;
    aspect-ratio: 1 / 1.05;
}

.skeleton-detail {
    display: grid;
    gap: 12px;
}

.skeleton-detail .image {
    height: 260px;
    border-radius: 14px;
}

.skeleton-detail .line-lg { height: 18px; }
.skeleton-detail .line-md { height: 14px; width: 80%; }
.skeleton-detail .line-sm { height: 12px; width: 60%; }

/* Inline loader for infinite scroll */
.inline-loader {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    color: var(--text-light, #777);
    font-size: 13px;
}

.inline-loader.active {
    display: flex;
}

.inline-spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid rgba(0,0,0,0.1);
    border-top-color: var(--loading-spinner);
    animation: loading-spin 0.9s linear infinite;
}

/* Micro interactions */
button,
.btn-primary,
.btn-secondary,
.nav-item,
.menu-btn,
.cart-btn,
.fab,
.attr-option {
    transition: transform 120ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

button:active,
.btn-primary:active,
.btn-secondary:active,
.nav-item:active,
.fab:active,
.attr-option:active {
    transform: scale(0.98);
}

.badge.pulse {
    animation: badge-pulse 600ms ease-out;
}

.btn-disabled {
    background: #f9d34f !important;
    color: #3a2e0f !important;
    cursor: not-allowed !important;
    opacity: 0.85;
    box-shadow: 0 4px 10px rgba(0,0,0,0.12) !important;
}

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

@keyframes loading-brand-shimmer {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes loading-liquid-fill {
    0%, 100% {
        background-position: 0% 100%;
        filter: drop-shadow(0 6px 10px rgba(185, 28, 28, 0.25));
    }
    50% {
        background-position: 0% 0%;
        filter: drop-shadow(0 8px 14px rgba(239, 68, 68, 0.35));
    }
}

@keyframes loading-liquid-shimmer {
    0% {
        text-shadow: 0 0 0 rgba(255, 255, 255, 0.0);
    }
    40% {
        text-shadow: 0 0 8px rgba(255, 255, 255, 0.35);
    }
    70% {
        text-shadow: 0 0 14px rgba(255, 255, 255, 0.55);
    }
    100% {
        text-shadow: 0 0 0 rgba(255, 255, 255, 0.0);
    }
}

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

@keyframes loading-pop {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

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

@keyframes badge-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

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

/* Notifications */
.notification-card {
    background: #fff;
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.05);
    margin-bottom: 12px;
    transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.notification-card.unread {
    border: 1px solid rgba(0,0,0,0.05);
    background: linear-gradient(135deg, rgba(0,0,0,0.015), rgba(0,0,0,0.04));
}
.notification-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.notification-title { font-weight: 700; color: #111; }
.notification-time { font-size: 12px; color: #888; }
.notification-body { margin-top: 6px; color: #333; line-height: 1.5; }
.notification-link { margin-top: 8px; color: var(--primary, #d32f2f); font-weight: 600; }
.menu-badge {
    display: none;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--primary, #d32f2f);
    color: #fff;
    font-size: 12px;
    align-items: center;
    justify-content: center;
    margin-inline-start: 6px;
}

/* Stock badge */
.stock-badge {
    position: absolute;
    top: 10px;
    inset-inline-start: 10px;
    padding: 8px 12px;
    border-radius: 12px;
    background: linear-gradient(135deg, #f9d34f, #f7c63a);
    color: #3a2e0f;
    font-size: 12px;
    font-weight: 800;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
    border: 1px solid rgba(0,0,0,0.12);
    text-align: center;
    max-width: 65%;
}
.stock-badge.stock-out {
    background: #f7d768;
    color: #7a4c00;
}
.product-detail-main {
    position: relative;
}
.product-detail-main .stock-badge {
    top: 12px;
    inset-inline-start: 12px;
    z-index: 3;
}
.btn-primary.btn-disabled,
.btn-lg.btn-disabled {
    background: #f7d768 !important;
    color: #7a4c00 !important;
    border: none !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.12) !important;
}
