/**
 * Estilos personalizados - Sistema de Tracking de Flota
 * Diseño elegante, moderno y minimalista
 */

/* =============================================
   VARIABLES CSS Y CONFIGURACIÓN BASE
   ============================================= */
:root {
    --primary-color: #0d6efd;
    --primary-dark: #0b5ed7;
    --primary-light: #3b82f6;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --border-color: #dee2e6;
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Tahoma', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f7fa;
    color: var(--dark-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: 1rem;
    color: var(--secondary-color);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

/* =============================================
   NAVBAR PERSONALIZADO
   ============================================= */
.navbar {
    backdrop-filter: blur(10px);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%) !important;
    padding: 0.75rem 0;
    transition: var(--transition);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
}

.navbar-brand i {
    font-size: 1.5rem;
}

.nav-link {
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    border-radius: var(--radius);
    transition: var(--transition);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.15);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.2);
}

.avatar-sm {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.dropdown-menu {
    border-radius: var(--radius-lg);
    padding: 0.5rem;
    margin-top: 0.5rem;
}

.dropdown-item {
    border-radius: var(--radius);
    padding: 0.625rem 1rem;
    font-weight: 500;
    transition: var(--transition);
}

.dropdown-item:hover {
    background-color: var(--light-color);
}

/* =============================================
   CARDS Y CONTENEDORES
   ============================================= */
.card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    background: white;
    transition: var(--transition);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    background: var(--light-color);
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

/* =============================================
   BOTONES
   ============================================= */
.btn {
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border: none;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #1e40af 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-outline-primary {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
    border: none;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #dc2626 100%);
    border: none;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* =============================================
   FORMULARIOS
   ============================================= */
.form-control, .form-select {
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    transition: var(--transition);
    background-color: white;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control::placeholder {
    color: #94a3b8;
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.input-group-text {
    background: var(--light-color);
    border: 2px solid var(--border-color);
    border-right: none;
    color: var(--secondary-color);
}

.input-group .form-control {
    border-left: none;
}

.input-group .form-control:focus {
    border-left: none;
}

/* =============================================
   ALERTAS Y NOTIFICACIONES
   ============================================= */
.alert {
    border: none;
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert i {
    font-size: 1.25rem;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.alert-info {
    background-color: #cffafe;
    color: #155e75;
}

/* =============================================
   BADGES
   ============================================= */
.badge {
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius);
}

.badge.bg-success {
    background-color: var(--success-color) !important;
}

.badge.bg-danger {
    background-color: var(--danger-color) !important;
}

.badge.bg-warning {
    background-color: var(--warning-color) !important;
}

.badge.bg-info {
    background-color: var(--info-color) !important;
}

.badge.bg-primary {
    background-color: var(--primary-color) !important;
}

/* =============================================
   TABLAS
   ============================================= */
.table {
    margin-bottom: 0;
}

.table thead th {
    background: var(--light-color);
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: var(--secondary-color);
    padding: 1rem;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
    background-color: #f8fafc;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* =============================================
   PÁGINA DE INICIO / LOGIN
   ============================================= */
.hero-section {
    min-height: calc(100vh - 76px);
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 50%, #f0f9ff 100%);
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 80%;
    height: 150%;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.1) 0%, transparent 70%);
    animation: float 20s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

.hero-section .container {
    position: relative;
    z-index: 2;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(5deg); }
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--secondary-color);
    margin-bottom: 2rem;
}

.login-card {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    max-width: 420px;
    width: 100%;
}

.login-card .form-control {
    padding: 0.875rem 1rem;
}

.login-card .btn {
    width: 100%;
    padding: 0.875rem;
    position: relative;
    z-index: 10;
}

.login-card form {
    position: relative;
    z-index: 5;
}

/* =============================================
   DASHBOARD
   ============================================= */
.dashboard-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 2rem 0;
    margin-bottom: 2rem;
    margin-top: -76px;
    padding-top: calc(76px + 2rem);
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
    height: 100%;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.stat-icon.bg-primary {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.1) 0%, rgba(37, 99, 235, 0.2) 100%);
    color: var(--primary-color);
}

.stat-icon.bg-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.2) 100%);
    color: var(--success-color);
}

.stat-icon.bg-warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(245, 158, 11, 0.2) 100%);
    color: var(--warning-color);
}

.stat-icon.bg-info {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.1) 0%, rgba(6, 182, 212, 0.2) 100%);
    color: var(--info-color);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark-color);
    line-height: 1;
}

.stat-label {
    color: var(--secondary-color);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* =============================================
   MAPA
   ============================================= */
.map-container {
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    background: white;
}

#map {
    height: 500px;
    width: 100%;
}

.map-controls {
    background: white;
    padding: 1rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.tracking-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--light-color);
    border-radius: var(--radius);
}

.tracking-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--secondary-color);
}

.tracking-indicator.active {
    background: var(--success-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* =============================================
   CONFIGURACIÓN
   ============================================= */
.settings-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.settings-section h5 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.interval-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.interval-option {
    flex: 1;
    min-width: 120px;
}

.interval-option input[type="radio"] {
    display: none;
}

.interval-option label {
    display: block;
    padding: 1rem;
    text-align: center;
    background: var(--light-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.interval-option label:hover {
    border-color: var(--primary-light);
}

.interval-option input[type="radio"]:checked + label {
    background: rgba(37, 99, 235, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
    font-weight: 600;
}

/* =============================================
   RUTAS Y HISTORIAL
   ============================================= */
.route-item {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
}

.route-item:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow-md);
}

.route-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.route-title {
    font-weight: 600;
    color: var(--dark-color);
}

.route-meta {
    display: flex;
    gap: 1.5rem;
    font-size: 0.875rem;
    color: var(--secondary-color);
}

.route-meta span {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

/* =============================================
   REPORTES
   ============================================= */
.report-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    height: 100%;
}

.report-card h5 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.chart-container {
    position: relative;
    height: 300px;
    margin-top: 1rem;
}

/* =============================================
   PERFIL DE USUARIO
   ============================================= */
.profile-header {
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 3rem;
    color: var(--primary-color);
    box-shadow: var(--shadow-lg);
}

.profile-body {
    padding: 2rem;
}

/* =============================================
   PAGINACIÓN
   ============================================= */
.pagination {
    gap: 0.25rem;
}

.page-link {
    border: none;
    border-radius: var(--radius);
    padding: 0.5rem 0.875rem;
    color: var(--secondary-color);
    font-weight: 500;
    transition: var(--transition);
}

.page-link:hover {
    background: var(--light-color);
    color: var(--primary-color);
}

.page-item.active .page-link {
    background: var(--primary-color);
    color: white;
}

/* =============================================
   MODAL PERSONALIZADO
   ============================================= */
.modal-content {
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

/* =============================================
   UTILIDADES
   ============================================= */
.text-primary { color: var(--primary-color) !important; }
.text-success { color: var(--success-color) !important; }
.text-danger { color: var(--danger-color) !important; }
.text-warning { color: var(--warning-color) !important; }
.text-info { color: var(--info-color) !important; }

.bg-primary-soft {
    background-color: rgba(37, 99, 235, 0.1) !important;
}

.bg-success-soft {
    background-color: rgba(16, 185, 129, 0.1) !important;
}

.bg-danger-soft {
    background-color: rgba(239, 68, 68, 0.1) !important;
}

.rounded-xl {
    border-radius: var(--radius-xl) !important;
}

.shadow-hover {
    transition: var(--transition);
}

.shadow-hover:hover {
    box-shadow: var(--shadow-lg) !important;
    transform: translateY(-2px);
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .login-card {
        padding: 1.5rem;
        margin: 0 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    #map {
        height: 350px;
    }
    
    .route-meta {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .interval-option {
        min-width: 100%;
    }
}

@media (max-width: 576px) {
    .main-content {
        padding-top: 66px;
    }
    
    .dashboard-header {
        padding-top: calc(66px + 1.5rem);
        padding-bottom: 1.5rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
    }
}

/* =============================================
   ANIMACIONES
   ============================================= */
.fade-in {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* =============================================
   LEAFLET MAP CUSTOMIZATIONS
   ============================================= */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.leaflet-popup-content {
    margin: 1rem;
    font-family: 'Inter', sans-serif;
}

.popup-content h6 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.popup-content p {
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

/* Custom marker */
.custom-marker {
    background: var(--primary-color);
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: var(--shadow);
}

/* =============================================
   LOADING SPINNER
   ============================================= */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--secondary-color);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h5 {
    margin-bottom: 0.5rem;
}

/* =============================================
   TOOLTIP CUSTOM
   ============================================= */
.tooltip {
    font-family: 'Inter', sans-serif;
}

.bs-tooltip-auto[data-popper-placement^=top] .tooltip-arrow::before,
.bs-tooltip-top .tooltip-arrow::before {
    border-top-color: var(--dark-color);
}

.tooltip-inner {
    background-color: var(--dark-color);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
}