/* Variables CSS para temas */
:root {
    /* Colores modo claro */
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-header: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    --text-primary: #333333;
    --text-secondary: #555555;
    --text-muted: #6c757d;
    --border-color: #e9ecef;
    --shadow-color: rgba(0,0,0,0.1);
    --card-bg: #ffffff;
    --input-bg: #f8f9fa;
    --modal-bg: #ffffff;
}

.dark-mode {
    /* Colores modo oscuro */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-header: linear-gradient(135deg, #1e2a3a 0%, #2c5282 100%);
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #8a8a8a;
    --border-color: #404040;
    --shadow-color: rgba(0,0,0,0.3);
    --card-bg: #2d2d2d;
    --input-bg: #3a3a3a;
    --modal-bg: #363636;
}

/* Aplicar variables a los elementos */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: all 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: var(--bg-header);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 4px 12px var(--shadow-color);
    border-bottom: 3px solid #2980b9;
}

.nav {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.8rem;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.nav-links {
    display: flex;
    gap: 15px;
    align-items: center;
}

.nav-links a {
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 25px;
    transition: all 0.3s ease;
    font-weight: 500;
    border: 2px solid transparent;
}

.nav-links a:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.3);
    transform: translateY(-2px);
}

/* Botón de tema */
.theme-toggle {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 2px solid rgba(255,255,255,0.3);
    padding: 8px 15px;
    border-radius: 25px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-2px);
}

.theme-icon {
    font-size: 16px;
}

.theme-text {
    white-space: nowrap;
}

/* Alertas */
.alert {
    padding: 15px 20px;
    margin-bottom: 25px;
    border-radius: 8px;
    border-left: 5px solid;
    box-shadow: 0 2px 10px var(--shadow-color);
    font-weight: 500;
}

.alert.success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-color: #28a745;
    color: #155724;
}

.alert.error {
    background: linear-gradient(135deg, #f8d7da 0%, #f1b0b7 100%);
    border-color: #dc3545;
    color: #721c24;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin: 40px 0;
}

.stat-card {
    background: linear-gradient(135deg, var(--card-bg) 0%, var(--bg-primary) 100%);
    padding: 30px 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-color);
    text-align: center;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px var(--shadow-color);
}

.stat-card h3 {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.stat-number {
    font-size: 3rem;
    font-weight: bold;
    color: var(--text-primary);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

/* Botones */
.actions {
    margin: 40px 0;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.btn {
    padding: 14px 30px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow-color);
    min-width: 140px;
}

.btn-primary {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2980b9 0%, #2471a3 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #7f8c8d 0%, #6c7a7d 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(149, 165, 166, 0.3);
}

.btn-outline {
    background: transparent;
    border: 2px solid #3498db;
    color: #3498db;
}

.btn-outline:hover {
    background: #3498db;
    color: white;
    transform: translateY(-2px);
}

/* Botones pequeños */
.btn-small {
    padding: 8px 16px;
    font-size: 13px;
    min-width: auto;
}

/* Formularios */
.visita-form {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow-color);
    max-width: 700px;
    margin: 0 auto;
    border: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 15px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s ease;
    background: var(--input-bg);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    background: var(--card-bg);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
}

.radio-group {
    display: flex;
    gap: 25px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.radio-group label {
    display: flex;
    align-items: center;
    font-weight: normal;
    cursor: pointer;
    padding: 10px 15px;
    background: var(--input-bg);
    border-radius: 8px;
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
    flex: 1;
    min-width: 150px;
    color: var(--text-primary);
}

.radio-group label:hover {
    background: var(--border-color);
    border-color: #3498db;
}

.radio-group input[type="radio"] {
    width: auto;
    margin-right: 10px;
    transform: scale(1.1);
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 40px;
    padding-top: 25px;
    border-top: 2px solid var(--border-color);
}

/* ===== MEJORAS ESPECÍFICAS PARA HISTORIAL ===== */

/* Header de sección con filtro - MEJORADO */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px 0;
    border-bottom: 2px solid var(--border-color);
}

.section-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.8rem;
    font-weight: 700;
}

/* Filtro de estado - MEJORADO */
.filtro-estado {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.filtro-form {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.filtro-form label {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    margin: 0;
    font-size: 0.95rem;
}

.filtro-form select {
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
    min-width: 180px;
}

.filtro-form select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Información del filtro - MEJORADO */
.filtro-info {
    background: var(--input-bg);
    padding: 18px 22px;
    border-radius: 10px;
    margin-bottom: 25px;
    border-left: 5px solid #3498db;
    box-shadow: 0 2px 8px var(--shadow-color);
}

.filtro-info p {
    margin: 0;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 1rem;
}

/* Título de visita mejorado - MEJORADO */
.visita-title {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.visita-title h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 700;
}

.fecha {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Grid de información - MEJORADO */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
    margin-bottom: 18px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    background: var(--input-bg);
    border-radius: 8px;
    border-left: 3px solid #3498db;
}

.info-item strong {
    color: var(--text-primary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.info-item span {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

.potencia {
    color: #e74c3c !important;
    font-weight: 700;
}

/* Observaciones - MEJORADO */
.observaciones {
    background: var(--input-bg);
    padding: 15px 18px;
    border-radius: 8px;
    border-left: 4px solid #3498db;
    margin-top: 12px;
    box-shadow: 0 2px 6px var(--shadow-color);
}

.observaciones strong {
    color: var(--text-primary);
    font-size: 0.9rem;
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.observaciones p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.5;
    font-size: 0.92rem;
}

/* Solución aplicada - NUEVO ESTILO */
.solucion-info {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    padding: 15px 18px;
    border-radius: 8px;
    border-left: 4px solid #28a745;
    margin-top: 12px;
    box-shadow: 0 2px 6px var(--shadow-color);
}

.solucion-info strong {
    color: #155724;
    font-size: 0.9rem;
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.solucion-info p {
    margin: 0;
    color: #155724;
    line-height: 1.5;
    font-size: 0.92rem;
}

.dark-mode .solucion-info {
    background: linear-gradient(135deg, #1a331f 0%, #2d4a32 100%);
    border-left-color: #28a745;
}

.dark-mode .solucion-info strong,
.dark-mode .solucion-info p {
    color: #51ff6c;
}

/* Ver más - MEJORADO */
.ver-mas {
    text-align: center;
    margin-top: 35px;
    padding-top: 25px;
    border-top: 2px solid var(--border-color);
}

.ver-mas p {
    margin-bottom: 18px;
    color: var(--text-muted);
    font-size: 1rem;
}

/* No data mejorado - MEJORADO */
.no-data {
    text-align: center;
    color: var(--text-muted);
    padding: 70px 40px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 2px dashed var(--border-color);
    margin: 30px 0;
}

.no-data p {
    font-size: 1.2rem;
    margin-bottom: 25px;
    font-weight: 500;
}

/* Mejoras para las tarjetas de visita - MEJORADO */
.visita-card {
    background: var(--card-bg);
    padding: 28px;
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-color);
    border-left: 6px solid #3498db;
    transition: all 0.3s ease;
    margin-bottom: 25px;
    border: 1px solid var(--border-color);
}

.visita-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px var(--shadow-color);
}

.visita-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 2px solid var(--border-color);
}

/* Acciones de visita - MEJORADO */
.visita-actions {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Estados con colores - MEJORADO */
.estado {
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.5px;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.estado.pendiente {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
    border: 1px solid #ffeaa7;
}

.estado.en_proceso {
    background: linear-gradient(135deg, #cce7ff 0%, #b3d7ff 100%);
    color: #004085;
    border: 1px solid #b3d7ff;
}

.estado.completada {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* Badge para solución - NUEVO */
.badge-solucion {
    background: #28a745;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    margin-left: 8px;
    font-weight: bold;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: var(--modal-bg);
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px var(--shadow-color);
    animation: slideIn 0.3s ease;
    color: var(--text-primary);
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    background: var(--bg-header);
    color: white;
    padding: 20px 25px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: white;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
}

.close:hover {
    color: #ecf0f1;
}

.modal-body {
    padding: 25px;
}

.modal-body p {
    margin-bottom: 15px;
    font-size: 15px;
    color: var(--text-primary);
}

/* Responsive - MEJORADO */
@media (max-width: 768px) {
    .nav {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .nav-links a {
        margin: 5px;
        padding: 8px 15px;
        font-size: 14px;
    }
    
    .theme-toggle {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .theme-text {
        display: none;
    }
    
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .filtro-estado {
        justify-content: center;
        width: 100%;
    }
    
    .filtro-form {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        width: 100%;
    }
    
    .filtro-form select {
        min-width: auto;
        width: 100%;
    }
    
    .visita-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .info-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 10px 12px;
        border-bottom: 1px solid var(--border-color);
        border-left: none;
        background: transparent;
    }
    
    .info-item:last-child {
        border-bottom: none;
    }
    
    .info-item strong {
        font-size: 0.8rem;
        min-width: 100px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .stat-number {
        font-size: 2.2rem;
    }
    
    .visita-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .visita-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .visita-card {
        padding: 20px;
    }
    
    .modal-content {
        margin: 5% auto;
        width: 95%;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .section-header h2 {
        font-size: 1.5rem;
    }
    
    .visita-title h3 {
        font-size: 1.1rem;
    }
}