/* =======================
   static/css/custom.css
   ======================= */

/* Variables CSS */
:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    
    --border-radius: 0.375rem;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --box-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    
    --transition: all 0.2s ease-in-out;
    
    /* Variables para compatibilidad con Bootstrap */
    --bs-primary-rgb: 13, 110, 253;
    --bs-success-rgb: 25, 135, 84;
    --bs-gray-300: #dee2e6;
    --bs-gray-400: #ced4da;
    --bs-gray-500: #adb5bd;
}

/* Utilidades generales */
.cursor-pointer {
    cursor: pointer;
}

.transition-all {
    transition: var(--transition);
}

/* Navbar personalizado */
.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
}

.navbar-nav .nav-link {
    font-weight: 500;
    transition: var(--transition);
}

.navbar-nav .nav-link:hover {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* Cards mejoradas */
.card {
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(0, 0, 0, 0.125);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--box-shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    background-color: rgba(13, 110, 253, 0.05);
    border-bottom: 1px solid rgba(13, 110, 253, 0.125);
}

.card-header.bg-primary {
    background-color: var(--primary-color) !important;
}

/* Avatares */
.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.875rem;
}

.avatar-large {
    width: 80px;
    height: 80px;
    font-size: 2rem;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
}

/* Badges personalizados */
.badge {
    font-size: 0.75em;
    font-weight: 500;
}

.badge.fs-6 {
    font-size: 0.875rem !important;
}

/* Botones mejorados */
.btn {
    font-weight: 500;
    transition: var(--transition);
    border-radius: var(--border-radius);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-group-sm > .btn,
.btn-sm {
    font-size: 0.8rem;
}

/* Formularios */
.form-control {
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.form-control:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.invalid-feedback.d-block {
    display: block !important;
    margin-top: 0.25rem;
}

/* Tablas responsivas */
.table-responsive {
    border-radius: var(--border-radius);
}

.table th {
    font-weight: 600;
    background-color: var(--light-color);
    border-top: none;
}

.table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

/* Timeline para historial */
.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--bs-gray-300);
}

.timeline-item {
    position: relative;
    margin-bottom: 2rem;
}

.timeline-marker {
    position: absolute;
    left: -30px;
    top: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    background: var(--bs-gray-400);
    box-shadow: 0 0 0 2px var(--bs-gray-300);
    z-index: 1;
}

.timeline-marker.bg-success {
    background: var(--success-color) !important;
    box-shadow: 0 0 0 2px var(--success-color);
}

.timeline-marker.bg-primary {
    background: var(--primary-color) !important;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.timeline-content {
    background: var(--light-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    border-left: 3px solid var(--bs-gray-300);
}

.timeline-item.current .timeline-content {
    border-left-color: var(--success-color);
    background: rgba(25, 135, 84, 0.05);
}

/* Alertas mejoradas */
.alert {
    border-radius: var(--border-radius);
    border: none;
}

.alert-dismissible .btn-close {
    padding: 0.75rem;
}

/* Paginación */
.pagination .page-link {
    border-radius: var(--border-radius);
    margin: 0 2px;
    border: 1px solid var(--bs-gray-300);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Breadcrumb */
.breadcrumb {
    background: transparent;
    padding: 0;
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--bs-gray-500);
}

/* Tooltips personalizados */
.tooltip .tooltip-inner {
    font-size: 0.8rem;
    border-radius: var(--border-radius);
}

/* Estados de carga */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--bs-gray-300);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Tabs personalizadas */
.nav-tabs .nav-link {
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    transition: var(--transition);
}

.nav-tabs .nav-link:hover {
    background-color: var(--light-color);
}

.nav-tabs .nav-link.active {
    background-color: white;
    border-bottom-color: white;
}

/* Pestañas de administrador siempre en línea */
.nav-tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    white-space: nowrap;
}

.nav-tabs .nav-item {
    flex-shrink: 0;
    white-space: nowrap;
}

.nav-tabs .nav-item.admin-tabs {
    display: inline-block !important;
}

.nav-tabs .nav-item .nav-link {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 0.85rem;
    padding: 0.5rem 0.7rem;
}

@media (max-width: 992px) {
    .nav-tabs .nav-item .nav-link {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
    }
    
    .nav-tabs .nav-item .nav-link i {
        display: none;
    }
}

/* Estilos para insignias */
.insignia-icon {
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.insignia-icon:hover {
    transform: scale(1.05);
}

/* Dropdown mejorados */
.dropdown-menu {
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.dropdown-item {
    transition: var(--transition);
}

.dropdown-item:hover {
    background-color: rgba(13, 110, 253, 0.1);
}

/* Estilos para el formulario de login */
.login-container {
    max-width: 400px;
    margin: 60px auto;
    padding: 2rem 2.5rem;
    background: var(--light-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow-lg);
    border: 1px solid var(--bs-gray-300);
    animation: fadeIn 0.4s;
}

.login-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-weight: 700;
}

.login-container label {
    font-weight: 500;
    margin-bottom: 0.25rem;
    display: block;
}

.login-container input[type="text"],
.login-container input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid var(--bs-gray-400);
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-size: 1rem;
}

.login-container input[type="text"]:focus,
.login-container input[type="password"]:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
    border-color: var(--primary-color);
}

.login-container button[type="submit"] {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 1rem;
    transition: var(--transition);
    cursor: pointer;
}

.login-container button[type="submit"]:hover {
    background: #0b5ed7;
}

.login-container .error-message {
    color: var(--danger-color);
    text-align: center;
    margin-bottom: 1rem;
    font-weight: 500;
}

/* Responsive utilities */
@media (max-width: 768px) {
    .table-responsive {
        border: none;
    }
    
    .table-responsive table {
        margin-bottom: 0;
    }
    
    .card {
        margin-bottom: 1rem;
    }
    
    .btn-group-sm > .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .avatar-large {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
}

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

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

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

.slide-in {
    animation: slideIn 0.3s ease-out;
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .card {
        border: 1px solid #dee2e6 !important;
        box-shadow: none !important;
    }
    
    .btn {
        display: none !important;
    }
}

/* Utilidades de texto - VERSIÓN COMPATIBLE */
.text-truncate-2 {
    overflow: hidden;
    display: block;
    max-height: 2.4em; /* aproximadamente 2 líneas */
    line-height: 1.2em;
}

.text-truncate-3 {
    overflow: hidden;
    display: block;
    max-height: 3.6em; /* aproximadamente 3 líneas */
    line-height: 1.2em;
}

/* Versión moderna para navegadores compatibles */
@supports (-webkit-line-clamp: 2) {
    .text-truncate-2 {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        max-height: none;
    }
    
    .text-truncate-3 {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
        max-height: none;
    }
}

/* Estados específicos */
.estado-activo {
    color: var(--success-color) !important;
}

.estado-prueba {
    color: var(--warning-color) !important;
}

.estado-inactivo {
    color: var(--danger-color) !important;
}

/* Footer sticky */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
}

/* Mejoras de accesibilidad */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible para accesibilidad */
.btn:focus-visible,
.form-control:focus-visible,
.nav-link:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Clases de utilidad adicionales */
.text-primary-custom {
    color: var(--primary-color) !important;
}

.bg-primary-light {
    background-color: rgba(13, 110, 253, 0.1) !important;
}

.border-primary-light {
    border-color: rgba(13, 110, 253, 0.3) !important;
}