/* Dashboard Custom Styles */

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Cards */
.card {
    border: none;
    border-radius: 10px;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
}

.card-header {
    border-bottom: 1px solid #dee2e6;
    border-radius: 10px 10px 0 0 !important;
}

/* Estilos para el selector de IMEIs */
#imeiSelect {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    transition: border-color 0.2s ease;
}

#imeiSelect:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

#imeiSelect option[value="__SELECT_ALL__"] {
    background-color: #e3f2fd !important;
    font-weight: bold !important;
    color: #1976d2 !important;
}

#imeiSelect option:disabled {
    color: #6c757d;
    font-style: italic;
}

#selectAllImeis {
    border-radius: 0 8px 8px 0;
}

.form-text.text-primary.fw-bold {
    color: #0d6efd !important;
}

#clearSelection {
    font-size: 0.875rem;
}

/* Altura fija para los contenedores de gráficos */
.card-body canvas {
    min-height: 400px !important;
}

/* Altura específica para los card-body que contienen gráficos */
#speedChart, #distanceChart, #violationsChart, #generalStatsChart, #geofenceChart {
    min-height: 400px;
    height: 400px;
}

/* Contenedores de gráficos con altura fija */
.chart-container {
    height: 450px;
    min-height: 450px;
}

/* Asegurar que los card-body de gráficos tengan altura suficiente */
.card-body:has(canvas) {
    min-height: 450px;
    padding: 1.5rem;
}

/* Para navegadores que no soportan :has() */
.card canvas {
    min-height: 400px;
}

.card .card-body {
    position: relative;
}

/* Statistics Cards */
.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.stat-card.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.stat-card.success {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%);
}

.stat-card.warning {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-card.info {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-card .stat-icon {
    font-size: 3rem;
    opacity: 0.8;
}

.stat-card .stat-number {
    font-size: 2.5rem;
    font-weight: bold;
}

.stat-card .stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
    margin: 1rem 0;
}

canvas {
    max-height: 300px;
}

/* Forms */
.form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: translateY(-1px);
}

/* Loading Spinner */
.spinner-border {
    width: 1.5rem;
    height: 1.5rem;
}

/* Tables */
.table th {
    border-top: none;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    vertical-align: middle;
    font-size: 0.9rem;
}

.table-striped > tbody > tr:nth-of-type(odd) > td {
    background-color: rgba(102, 126, 234, 0.05);
}

/* Navigation */
.navbar-brand {
    font-weight: 600;
    font-size: 1.3rem;
}

.navbar {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Connection Status */
.connection-status {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 500;
}

.connection-status.connected {
    background-color: rgba(40, 167, 69, 0.1);
    color: #28a745;
}

.connection-status.disconnected {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .stat-card .stat-number {
        font-size: 2rem;
    }
    
    .stat-card .stat-icon {
        font-size: 2.5rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    canvas {
        max-height: 250px;
    }
    
    #speedChart, #distanceChart, #violationsChart, #generalStatsChart, #geofenceChart {
        min-height: 300px;
        height: 300px;
    }
    
    .chart-container {
        height: 350px;
        min-height: 350px;
    }
    
    .card-body:has(canvas) {
        min-height: 350px;
    }
}

/* Tooltips for charts */
.chartjs-tooltip {
    opacity: 1;
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    pointer-events: none;
    transform: translate(-50%, -100%);
    margin-top: -10px;
}

/* Custom scrollbar */
.table-responsive::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Tab styling */
.nav-tabs .nav-link {
    border: none;
    color: #666;
    font-weight: 500;
}

.nav-tabs .nav-link.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px 8px 0 0;
}

/* Error and success states */
.alert {
    border: none;
    border-radius: 10px;
    font-weight: 500;
}

.alert-danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    color: white;
}

.alert-info {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.alert-success {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e6cf 100%);
    color: white;
}

/* Footer */
footer {
    margin-top: auto;
    border-top: 1px solid #dee2e6;
}

/* Ranking de Velocidades - Top 10 Styles */
.ranking {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 0.5rem;
    min-width: 28px;
    text-align: center;
}

/* Estilos especiales para el podio (top 3) */
.top-1 .ranking {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #333;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.top-2 .ranking {
    background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
    color: #333;
    box-shadow: 0 2px 8px rgba(192, 192, 192, 0.3);
}

.top-3 .ranking {
    background: linear-gradient(135deg, #cd7f32 0%, #d4af37 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(205, 127, 50, 0.3);
}

/* Destacar filas del podio */
.top-1 {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.1) 0%, rgba(255, 215, 0, 0.05) 100%);
    border-left: 4px solid #ffd700;
}

.top-2 {
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.1) 0%, rgba(192, 192, 192, 0.05) 100%);
    border-left: 4px solid #c0c0c0;
}

.top-3 {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.1) 0%, rgba(205, 127, 50, 0.05) 100%);
    border-left: 4px solid #cd7f32;
}

/* Tabla de Excesos de Velocidad - Estilos Mejorados */
#violationsTable .badge {
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
    min-width: 30px;
}

#violationsTable .bg-warning {
    background-color: #ffc107 !important;
    color: #000;
}

#violationsTable .bg-danger {
    background-color: #dc3545 !important;
}

#violationsTable .bg-secondary {
    background-color: #6c757d !important;
}

/* Resaltar filas según severidad */
#violationsTable .table-danger {
    background-color: rgba(220, 53, 69, 0.1) !important;
    border-left: 4px solid #dc3545;
}

#violationsTable .table-warning {
    background-color: rgba(255, 193, 7, 0.1) !important;
    border-left: 4px solid #ffc107;
}

#violationsTable .table-info {
    background-color: rgba(13, 202, 240, 0.1) !important;
    border-left: 4px solid #0dcaf0;
}

/* Hover effects para excesos */
#violationsTable tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.075) !important;
    transform: translateX(2px);
    transition: all 0.2s ease;
}

/* Ranking de Excesos - Medallas */
.ranking-violation {
    display: inline-block;
    font-size: 1.2rem;
    margin-right: 0.5rem;
    animation: bounceIn 0.6s ease-out;
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Efectos especiales para el top 3 de excesos */
#violationsTable tbody tr:nth-child(1) {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 215, 0, 0.05) 100%);
    box-shadow: 0 2px 4px rgba(255, 215, 0, 0.2);
}

#violationsTable tbody tr:nth-child(2) {
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.15) 0%, rgba(192, 192, 192, 0.05) 100%);
    box-shadow: 0 2px 4px rgba(192, 192, 192, 0.2);
}

#violationsTable tbody tr:nth-child(3) {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.15) 0%, rgba(205, 127, 50, 0.05) 100%);
    box-shadow: 0 2px 4px rgba(205, 127, 50, 0.2);
}
