/* Real-time Dashboard UI Components */

/* Live Status Indicators */
.lf-realtime-status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-left: 0.75rem;
}

.lf-realtime-status--connecting {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    border: 1px solid #f59e0b;
}

.lf-realtime-status--offline {
    background: linear-gradient(135deg, #fecaca 0%, #f87171 100%);
    color: #991b1b;
    border: 1px solid #dc2626;
}

/* Connected Live Status */
.lf-realtime-status:not(.lf-realtime-status--connecting):not(.lf-realtime-status--offline) {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border: 1px solid #10b981;
    position: relative;
    overflow: hidden;
}

/* Pulsing dot animation for live indicator */
.lf-live-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    color: #10b981;
    animation: livePulse 2s infinite;
}

@keyframes livePulse {
    0%, 100% { 
        opacity: 1;
        transform: scale(1);
    }
    50% { 
        opacity: 0.6;
        transform: scale(1.1);
    }
}

/* Live indicator for status banner */
.lf-live-indicator {
    position: relative;
}

.lf-live-indicator::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: livePulse 2s infinite;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

/* Connecting spinner animation */
.lf-realtime-status--connecting .fa-spinner {
    animation: spin 1s linear infinite;
}

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

/* Real-time data updates flash effect */
.lf-realtime-update {
    animation: dataFlash 0.3s ease-in-out;
}

@keyframes dataFlash {
    0% { background-color: rgba(16, 185, 129, 0.1); }
    50% { background-color: rgba(16, 185, 129, 0.2); }
    100% { background-color: transparent; }
}

/* Last update timestamp */
.lf-last-update {
    font-size: 0.625rem;
    color: #6b7280;
    font-style: italic;
    margin-top: 0.25rem;
}

/* Emergency alert styles */
.lf-emergency-alert {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border: 2px solid #ef4444;
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin: 0.5rem 0;
    animation: emergencyPulse 1s ease-in-out infinite alternate;
}

@keyframes emergencyPulse {
    from { 
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    to { 
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
    }
}

/* WebSocket connection quality indicator */
.lf-connection-quality {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.lf-connection-quality-bar {
    width: 3px;
    height: 12px;
    background: #d1d5db;
    border-radius: 1px;
    transition: background-color 0.3s ease;
}

.lf-connection-quality-bar.active {
    background: #10b981;
}

.lf-connection-quality-bar.weak {
    background: #f59e0b;
}

.lf-connection-quality-bar.poor {
    background: #ef4444;
}

/* Driver location indicator */
.lf-driver-location {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border: 1px solid #3b82f6;
    border-radius: 0.375rem;
    color: #1e40af;
    font-size: 0.75rem;
    font-weight: 500;
}

.lf-driver-location .fa-map-marker-alt {
    color: #3b82f6;
    animation: locationBounce 2s infinite;
}

@keyframes locationBounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-3px); }
    60% { transform: translateY(-2px); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .lf-realtime-status {
        font-size: 0.625rem;
        padding: 0.1875rem 0.375rem;
        margin-left: 0.5rem;
    }
    
    .lf-live-text, .lf-connecting-text, .lf-offline-text {
        display: none;
    }
    
    .lf-realtime-status {
        min-width: 1.5rem;
        justify-content: center;
    }
}

/* Smooth transitions for all real-time elements */
.lf-realtime-status,
.lf-live-indicator,
.lf-driver-location,
.lf-emergency-alert {
    transition: all 0.3s ease;
}

/* Enhanced visibility for critical states */
.lf-realtime-status--offline,
.lf-emergency-alert {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Success state animation */
.lf-realtime-status:not(.lf-realtime-status--connecting):not(.lf-realtime-status--offline)::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Real-time Updates Section */
.lf-realtime-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 0.75rem;
    border: 1px solid #bae6fd;
}

.lf-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.lf-realtime-grid {
    display: grid;
    gap: 1rem;
    margin: 1rem 0;
}

.lf-realtime-card {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 0.5rem;
    border: 1px solid rgba(59, 130, 246, 0.2);
    transition: all 0.3s ease;
    animation: slideInFromRight 0.3s ease-out;
}

.lf-realtime-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

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

.lf-realtime-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    border-radius: 50%;
    color: white;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.lf-realtime-icon--calendar {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.lf-realtime-content {
    flex: 1;
}

.lf-realtime-title {
    font-weight: 600;
    color: #1e40af;
    margin: 0 0 0.25rem 0;
    font-size: 0.875rem;
}

.lf-realtime-description {
    color: #6b7280;
    margin: 0 0 0.5rem 0;
    font-size: 0.75rem;
    line-height: 1.4;
}

.lf-realtime-timestamp {
    color: #9ca3af;
    font-size: 0.625rem;
    font-style: italic;
}

/* Emergency Section */
.lf-emergency-section {
    margin: 1rem 0;
}

.lf-emergency-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    margin-bottom: 0.5rem;
    animation: slideInFromRight 0.3s ease-out;
}

.lf-emergency-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-radius: 50%;
    color: white;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.lf-emergency-content {
    flex: 1;
}

.lf-emergency-title {
    font-weight: 700;
    color: #991b1b;
    margin: 0 0 0.25rem 0;
    font-size: 0.875rem;
}

.lf-emergency-message {
    color: #7c2d12;
    margin: 0 0 0.5rem 0;
    font-size: 0.8125rem;
    line-height: 1.4;
    font-weight: 500;
}

.lf-emergency-timestamp {
    color: #a16207;
    font-size: 0.625rem;
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
    .lf-realtime-section {
        margin: 1rem 0;
        padding: 1rem;
    }
    
    .lf-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .lf-realtime-card,
    .lf-emergency-alert {
        padding: 0.75rem;
    }
    
    .lf-realtime-icon,
    .lf-emergency-icon {
        width: 2rem;
        height: 2rem;
        font-size: 0.75rem;
    }
}

/* Scroll animations for new items */
.lf-realtime-card.new-item,
.lf-emergency-alert.new-item {
    animation: newItemAppear 0.5s ease-out;
}

@keyframes newItemAppear {
    0% {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    50% {
        opacity: 0.7;
        transform: translateY(-5px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}