/**
 * CSS for Background Refresh Visual Enhancements
 * SAMPARK - Support and Mediation Portal for All Rail Cargo
 */

/* Refreshing indicator */
.dataTables_wrapper.refreshing::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, #007bff, transparent);
    background-size: 50% 100%;
    animation: refreshProgress 2s linear infinite;
    z-index: 10;
}

@keyframes refreshProgress {
    0% { background-position: -50% 0; }
    100% { background-position: 150% 0; }
}

/* Urgent ticket highlighting */
.urgent-ticket {
    background-color: #fff3cd !important;
    border-left: 4px solid #ffc107;
}

.urgent-ticket:hover {
    background-color: #fff1b3 !important;
}

/* SLA violation highlighting */
.sla-violation {
    background-color: #f8d7da !important;
    border-left: 4px solid #dc3545;
}

.sla-violation:hover {
    background-color: #f5c6cb !important;
}

/* Priority badges */
.priority-badge {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 60px;
    text-align: center;
}

.priority-badge.badge-danger {
    background-color: #dc3545;
    animation: pulse 2s infinite;
}

.priority-badge.badge-warning {
    background-color: #ffc107;
    color: #212529;
}

.priority-badge.badge-info {
    background-color: #17a2b8;
}

.priority-badge.badge-secondary {
    background-color: #6c757d;
}

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

/* Status badges */
.status-badge {
    font-size: 0.75rem;
    min-width: 80px;
    text-align: center;
}

/* Stats update animation */
.stat-updated {
    animation: statHighlight 1s ease-in-out;
}

@keyframes statHighlight {
    0% { background-color: transparent; }
    50% { background-color: #28a745; color: #000; border-radius: 4px; }
    100% { background-color: transparent; }
}

/* Ticket link enhancements */
.ticket-link {
    font-weight: 600;
    text-decoration: none;
}

.ticket-link:hover {
    text-decoration: underline;
}

.ticket-link.text-danger {
    position: relative;
}

.ticket-link.text-danger::after {
    content: '⚠';
    font-size: 0.8em;
    margin-left: 4px;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* DataTable responsive enhancements */
.dataTables_wrapper .dataTables_processing {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 20px;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* Custom scrollbar for DataTables */
.dataTables_scrollBody::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.dataTables_scrollBody::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}

.dataTables_scrollBody::-webkit-scrollbar-thumb {
    background: #6c757d;
    border-radius: 4px;
}

.dataTables_scrollBody::-webkit-scrollbar-thumb:hover {
    background: #495057;
}

/* Refresh notification */
#refresh-notification {
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease-in-out;
}

#refresh-notification.show {
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading states */
.table-loading {
    position: relative;
    opacity: 0.7;
    pointer-events: none;
}

.table-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Last refresh time styling */
.last-refresh-time {
    font-size: 0.75rem;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.last-refresh-time:hover {
    opacity: 1;
}

/* Category labels */
.category-label {
    font-weight: 500;
    color: #495057;
}

/* Enhanced tooltips for ticket data */
.tooltip-inner {
    max-width: 300px;
    text-align: left;
    background-color: #1a1a1a;
}

.tooltip.bs-tooltip-top .arrow::before {
    border-top-color: #1a1a1a;
}

/* Responsive enhancements */
@media (max-width: 768px) {
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        text-align: center;
        margin-bottom: 1rem;
    }
    
    .priority-badge,
    .status-badge {
        font-size: 0.65rem;
        min-width: 50px;
    }
    
    #refresh-notification {
        left: 10px;
        right: 10px;
        min-width: auto;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .urgent-ticket {
        background-color: #856404 !important;
        color: #fff3cd;
    }
    
    .sla-violation {
        background-color: #721c24 !important;
        color: #f8d7da;
    }
    
    .tooltip-inner {
        background-color: #f8f9fa;
        color: #212529;
    }
    
    .tooltip.bs-tooltip-top .arrow::before {
        border-top-color: #f8f9fa;
    }
}

/* Print styles */
@media print {
    .urgent-ticket {
        background-color: transparent !important;
        border-left: 4px solid #000;
    }
    
    .sla-violation {
        background-color: transparent !important;
        border-left: 4px solid #000;
        font-weight: bold;
    }
    
    .priority-badge,
    .status-badge {
        background-color: transparent !important;
        color: #000 !important;
        border: 1px solid #000;
    }
    
    #refresh-notification {
        display: none !important;
    }
}

/* Accessibility improvements */
.urgent-ticket:focus,
.sla-violation:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .urgent-ticket {
        border-left-width: 6px;
        border-left-color: #000;
    }
    
    .sla-violation {
        border-left-width: 6px;
        border-left-color: #000;
    }
    
    .priority-badge,
    .status-badge {
        border: 2px solid #000;
        font-weight: bold;
    }
}

/* Animation preferences */
@media (prefers-reduced-motion: reduce) {
    .priority-badge.badge-danger {
        animation: none;
    }
    
    .ticket-link.text-danger::after {
        animation: none;
    }
    
    .stat-updated {
        animation: none;
        background-color: #28a745;
        color: #000;
        border-radius: 4px;
        transition: none;
    }
    
    .refreshing::before {
        animation: none;
    }
}