/**
 * Real-Time Updates Styling
 * Animations, notifications, and visual indicators for live updates
 */

/* Real-time Update Animation */
@keyframes realtimeUpdate {
    0% {
        background-color: rgba(59, 130, 246, 0.1);
        transform: scale(1);
    }
    50% {
        background-color: rgba(59, 130, 246, 0.2);
        transform: scale(1.02);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

.realtime-update {
    animation: realtimeUpdate 0.6s ease-out !important;
}

/* Update Badge */
.realtime-update-badge {
    display: inline-block;
    padding: 4px 8px;
    margin-left: 8px;
    background: #10b981;
    color: white;
    font-size: 0.75rem;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-weight: 600;
}

.realtime-update-badge.show {
    opacity: 1;
}

/* Alert Badge with Counter */
.alert-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    margin-left: 6px;
    background: #e5e7eb;
    color: #374151;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    transition: all 0.3s ease;
}

.alert-badge.has-alerts {
    background: #ef4444;
    color: white;
    animation: alertPulse 0.5s ease;
}

@keyframes alertPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Real-Time Notifications */
@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.realtime-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 380px;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.4s ease-out;
}

.realtime-notification.show {
    opacity: 1;
}

.realtime-notification:not(.show) {
    animation: slideOutRight 0.4s ease-out;
}

/* Notification Types */
.notification-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 4px solid #3b82f6;
}

.notification-success {
    background: #dcfce7;
    color: #166534;
    border-left: 4px solid #10b981;
}

.notification-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

.notification-danger {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.notification-icon {
    font-weight: 700;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.notification-message {
    flex: 1;
}

/* Status Indicators */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-processing {
    background: #dbeafe;
    color: #1e40af;
}

.status-completed {
    background: #dcfce7;
    color: #166534;
}

.status-cancelled {
    background: #fee2e2;
    color: #991b1b;
}

.status-rejected {
    background: #fee2e2;
    color: #991b1b;
}

/* Stock Status */
.stock-status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.stock-status.in_stock {
    background: #dcfce7;
    color: #166534;
}

.stock-status.out_of_stock {
    background: #fee2e2;
    color: #991b1b;
}

/* Payment Status */
.payment-status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.payment-status.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.payment-status.status-fully_paid,
.payment-status.status-paid {
    background: #dcfce7;
    color: #166534;
}

.payment-status.status-partially_paid {
    background: #dbeafe;
    color: #1e40af;
}

.payment-status.status-rejected {
    background: #fee2e2;
    color: #991b1b;
}

.payment-status.status-failed {
    background: #fee2e2;
    color: #991b1b;
}

/* Alert Items */
.alert-item {
    padding: 10px 12px;
    margin: 8px 0;
    border-radius: 6px;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
}

.alert-item strong {
    flex: 1;
}

.alert-item .amount {
    font-weight: 700;
    color: #059669;
}

.alert-item .status {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.1);
}

.alert-item small {
    color: rgba(0, 0, 0, 0.6);
    font-size: 0.8rem;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-left: 3px solid #3b82f6;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border-left: 3px solid #ef4444;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border-left: 3px solid #10b981;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 3px solid #f59e0b;
}

/* Real-time Container */
[data-realtime] {
    position: relative;
    transition: all 0.3s ease;
}

[data-realtime].loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Pulse Animation for Live Elements */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.realtime-live {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Loading Indicator */
.realtime-loading {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Mobile Responsive */
@media (max-width: 640px) {
    .realtime-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        animation: slideInUp 0.4s ease-out;
    }

    .realtime-notification:not(.show) {
        animation: slideOutDown 0.4s ease-out;
    }

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

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

/* Shimmer Loading Animation */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.realtime-shimmer {
    background: linear-gradient(
        90deg,
        #f3f4f6 0%,
        #e5e7eb 50%,
        #f3f4f6 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* Connection Status Indicator */
.realtime-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.realtime-status.connected {
    background: #dcfce7;
    color: #166534;
}

.realtime-status.connected::before {
    content: '●';
    color: #10b981;
    animation: pulse 2s infinite;
}

.realtime-status.disconnected {
    background: #fee2e2;
    color: #991b1b;
}

.realtime-status.disconnected::before {
    content: '●';
    color: #ef4444;
}

/* Responsive adjustments for different screen sizes */
@media (max-width: 768px) {
    .status-badge,
    .stock-status,
    .payment-status,
    .alert-badge {
        font-size: 0.8rem;
        padding: 3px 6px;
    }

    .alert-item {
        flex-direction: column;
        align-items: flex-start;
    }
}
