/* =====================================
   SMART STOCK DISPLAY SYSTEM
   ===================================== */

/* Stock indicator base styling */
.stock-indicator {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    animation: fadeIn 0.3s ease;
    margin-bottom: 0.5rem;
}

/* Critical stock (1-3 items) */
.stock-critical {
    background: linear-gradient(45deg, #ff4757, #ff6b7a);
    color: white;
    animation: urgentPulse 2s infinite;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.3);
}

/* Low stock (4-10 items) */
.stock-low {
    background: linear-gradient(45deg, #ffa502, #ffb84d);
    color: white;
    box-shadow: 0 2px 8px rgba(255, 165, 2, 0.3);
}

/* Moderate stock (11-25 items) */
.stock-available {
    background: linear-gradient(45deg, #3742fa, #5352ed);
    color: white;
    box-shadow: 0 2px 8px rgba(55, 66, 250, 0.3);
}

/* High stock (25+ items) */
.stock-plenty {
    background: linear-gradient(45deg, #2ed573, #7bed9f);
    color: white;
    box-shadow: 0 2px 8px rgba(46, 213, 115, 0.3);
}

/* Out of stock */
.stock-out {
    background: linear-gradient(45deg, #57606f, #747d8c);
    color: white;
    opacity: 0.8;
}

/* Urgency pulse animation for critical stock */
@keyframes urgentPulse {
    0%, 100% { 
        transform: scale(1); 
        box-shadow: 0 2px 8px rgba(255, 71, 87, 0.3);
    }
    50% { 
        transform: scale(1.05); 
        box-shadow: 0 4px 16px rgba(255, 71, 87, 0.5);
    }
}

/* Fade in animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Urgency message styling */
.urgency-message {
    font-size: 0.85rem;
    color: #e74c3c;
    font-weight: 600;
    margin-top: 5px;
    animation: fadeInUp 0.5s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

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

/* Product card stock badges - INLINE next to product title */
.badge-urgent-inline,
.badge-low-inline,
.badge-available-inline,
.badge-in-stock-inline,
.badge-out-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* RTL Support: Reverse icon and text order */
[dir="rtl"] .badge-urgent-inline,
[dir="rtl"] .badge-low-inline,
[dir="rtl"] .badge-available-inline,
[dir="rtl"] .badge-in-stock-inline,
[dir="rtl"] .badge-out-inline {
    flex-direction: row-reverse;
}

/* Stock Badge Wrapper - Controls positioning */
.stock-badge-wrapper {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* RTL: Move badge to LEFT side (appears after title in Arabic) */
[dir="rtl"] .stock-badge-wrapper {
    order: -1;
}

.badge-urgent-inline {
    background: linear-gradient(45deg, #ff4757, #ff3838);
    color: white;
    animation: badgePulse 2s infinite;
    box-shadow: 0 3px 10px rgba(255, 71, 87, 0.5);
}

.badge-low-inline {
    background: linear-gradient(45deg, #ffa502, #ff9500);
    color: white;
    box-shadow: 0 3px 10px rgba(255, 165, 2, 0.5);
    animation: badgeGlow 2s infinite;
}

.badge-available-inline {
    background: linear-gradient(45deg, #3742fa, #5352ed);
    color: white;
    box-shadow: 0 3px 10px rgba(55, 66, 250, 0.5);
}

.badge-in-stock-inline {
    background: linear-gradient(45deg, #2ed573, #27ae60);
    color: white;
    box-shadow: 0 3px 10px rgba(46, 213, 115, 0.5);
    animation: badgeShine 3s infinite;
}

.badge-out-inline {
    background: linear-gradient(45deg, #57606f, #747d8c);
    color: white;
    box-shadow: 0 3px 10px rgba(87, 96, 111, 0.5);
    opacity: 0.9;
}

/* Product card title wrapper */
.product-title {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}

/* Product card stock badges - MOVED TO TOP RIGHT to avoid price overlap */
.stock-badge-top-right {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 10;
}

/* RTL support - move to top right for Arabic */
[dir="rtl"] .stock-badge-top-right {
    right: 0.5rem;
    left: auto;
}

/* Legacy bottom-right positioning (deprecated - keeping for compatibility) */
.stock-badge-bottom-right {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    z-index: 10;
}

/* RTL support - move to bottom left for Arabic */
[dir="rtl"] .stock-badge-bottom-right {
    left: 0.5rem;
    right: auto;
}

.badge-urgent {
    background: linear-gradient(45deg, #ff4757, #ff3838);
    color: white;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 16px;
    font-weight: 700;
    animation: badgePulse 2s infinite;
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-low {
    background: linear-gradient(45deg, #ffa502, #ff9500);
    color: white;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 16px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(255, 165, 2, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: badgeGlow 2s infinite;
}

.badge-available {
    background: linear-gradient(45deg, #3742fa, #5352ed);
    color: white;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 16px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(55, 66, 250, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: badgeShine 3s infinite;
}

.badge-in-stock {
    background: linear-gradient(45deg, #2ed573, #27ae60);
    color: white;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 16px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(46, 213, 115, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-out {
    background: linear-gradient(45deg, #57606f, #747d8c);
    color: white;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 16px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(87, 96, 111, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

@keyframes badgePulse {
    0%, 100% { 
        transform: scale(1); 
        box-shadow: 0 4px 12px rgba(255, 71, 87, 0.5);
    }
    50% { 
        transform: scale(1.08); 
        box-shadow: 0 6px 16px rgba(255, 71, 87, 0.7);
    }
}

@keyframes badgeGlow {
    0%, 100% { 
        box-shadow: 0 4px 12px rgba(255, 165, 2, 0.5);
    }
    50% { 
        box-shadow: 0 6px 16px rgba(255, 165, 2, 0.7);
    }
}

@keyframes badgeShine {
    0%, 100% { 
        box-shadow: 0 4px 12px rgba(55, 66, 250, 0.5);
    }
    50% { 
        box-shadow: 0 6px 16px rgba(55, 66, 250, 0.7);
    }
}

/* RTL support for stock indicators */
html[lang="ar"] .stock-indicator {
    direction: rtl;
}

html[lang="ar"] .urgency-message {
    direction: rtl;
}

html[lang="ar"] .stock-badge-top-right {
    right: 0.5rem;
    left: auto;
}

html[lang="ar"] .stock-badge-bottom-right {
    left: 0.5rem;
    right: auto;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .stock-indicator {
        font-size: 0.8rem;
        padding: 6px 12px;
        gap: 6px;
    }
    
    .urgency-message {
        font-size: 0.75rem;
    }
    
    .card-stock-badge .badge-urgent,
    .card-stock-badge .badge-low,
    .card-stock-badge .badge-available {
        font-size: 0.65rem;
        padding: 3px 6px;
    }
}

/* Hover effects for interactive elements */
.stock-indicator:hover {
    transform: translateY(-1px);
    transition: transform 0.2s ease;
}

/* Special styling for product detail page */
.product-detail .stock-section {
    margin: 1rem 0;
}

.product-detail .stock-indicator {
    font-size: 1rem;
    padding: 10px 20px;
}

.product-detail .urgency-message {
    font-size: 0.9rem;
    margin-top: 8px;
}

/* Clock icon animation for urgency */
.stock-urgency-icon {
    animation: clockTick 1s infinite;
    display: inline-block;
}

@keyframes clockTick {
    0%, 50%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(10deg); }
    75% { transform: rotate(-10deg); }
}

/* Pulsing text animation for urgency messages */
.stock-urgency-pulse {
    animation: urgencyTextPulse 1.5s infinite;
}

@keyframes urgencyTextPulse {
    0%, 100% { 
        transform: scale(1);
        text-shadow: 0 0 0 rgba(255, 71, 87, 0);
    }
    50% { 
        transform: scale(1.02);
        text-shadow: 0 0 8px rgba(255, 71, 87, 0.3);
    }
}

/* Quantity validation styles */
.quantity-input.is-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

.quantity-error {
    font-size: 0.875rem;
    color: #dc3545;
    font-weight: 500;
    animation: fadeInUp 0.3s ease;
    text-align: left;
}

/* RTL support for quantity validation */
[dir="rtl"] .quantity-error,
html[lang="ar"] .quantity-error {
    text-align: right;
    direction: rtl;
}

[dir="rtl"] .quantity-input,
html[lang="ar"] .quantity-input {
    direction: rtl;
}

/* RTL quantity selector styling */
[dir="rtl"] .quantity-selector,
html[lang="ar"] .quantity-selector {
    direction: rtl;
}

[dir="rtl"] .quantity-selector label,
html[lang="ar"] .quantity-selector label {
    text-align: right;
}

/* Enhanced validation feedback animations */
.quantity-input.is-invalid {
    animation: invalidInputShake 0.5s ease-in-out;
}

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

/* RTL version of shake animation */
[dir="rtl"] .quantity-input.is-invalid,
html[lang="ar"] .quantity-input.is-invalid {
    animation: invalidInputShakeRTL 0.5s ease-in-out;
}

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

/* Error message slide in animations */
.quantity-error {
    transform: translateY(-10px);
    opacity: 0;
    transition: all 0.3s ease;
}

.quantity-error[style*="block"] {
    transform: translateY(0);
    opacity: 1;
}

/* Real-time stock update indicators */
.stock-updating {
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.stock-updated {
    animation: stockUpdated 0.5s ease;
}

@keyframes stockUpdated {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
