/**
 *
 * @package   Ven911Core
 * @author    Jose Agustin Brito <jose.brito.911apure@gmail.com>
 * @copyright Copyright (C) 2025 Jose Agustin Brito
 * @license   GNU GPL v3 - https://www.gnu.org/licenses/gpl-3.0.html
 * 
 * Este software es libre: puedes redistribuirlo y/o modificarlo
 * bajo los términos de la GNU GPL v3.
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============================================
   ESTILOS GENERALES
   ============================================ */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.contenedor-principal {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    overflow: hidden;
}

/* ============================================
   ENCABEZADO
   ============================================ */
.encabezado {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.encabezado h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.encabezado p {
    font-size: 1.1em;
    opacity: 0.9;
}

/* ============================================
   DASHBOARD - GRID DE TARJETAS
   ============================================ */
.contenedor-dashboard {
    padding: 40px 30px;
}

.titulo-seccion {
    text-align: center;
    color: #2a5298;
    margin-bottom: 30px;
    font-size: 1.8em;
}

.grid-formularios {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

/* ============================================
   TARJETAS DE FORMULARIOS
   ============================================ */
.tarjeta-formulario {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.tarjeta-formulario::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.tarjeta-formulario:hover::before {
    transform: scaleX(1);
}

.tarjeta-formulario:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.3);
    border-color: #667eea;
}

.icono-formulario {
    font-size: 3em;
    margin-bottom: 15px;
    color: #667eea;
}

.tarjeta-formulario h3 {
    color: #2a5298;
    margin-bottom: 10px;
    font-size: 1.3em;
}

.tarjeta-formulario p {
    color: #666;
    font-size: 0.95em;
    line-height: 1.5;
}

/* ============================================
   FORMULARIOS
   ============================================ */
.contenedor-formulario {
    padding: 40px 30px;
    display: none;
}

.contenedor-formulario.activo {
    display: block;
}

.formulario {
    max-width: 800px;
    margin: 0 auto;
}

.grupo-campo {
    margin-bottom: 20px;
}

.grupo-campo label {
    display: block;
    margin-bottom: 8px;
    color: #2a5298;
    font-weight: 600;
    font-size: 0.95em;
}

.grupo-campo label .requerido {
    color: #e74c3c;
    margin-left: 3px;
}

.grupo-campo input,
.grupo-campo select,
.grupo-campo textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    transition: all 0.3s ease;
    background: white;
}

.grupo-campo input[type="file"] {
    padding: 8px 12px;
    cursor: pointer;
    border: 2px dashed #e0e0e0;
}

.grupo-campo input[type="file"]:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.grupo-campo input:focus,
.grupo-campo select:focus,
.grupo-campo textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.grupo-campo textarea {
    min-height: 100px;
    resize: vertical;
}

.grupo-campo small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 0.85em;
    font-style: italic;
}

/* ============================================
   GRID DE CAMPOS (2 columnas)
   ============================================ */
.fila-campos {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* ============================================
   BOTONES
   ============================================ */
.contenedor-botones {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

.boton {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.boton-primario {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.boton-primario:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.boton-secundario {
    background: #95a5a6;
    color: white;
}

.boton-secundario:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
}

.boton-volver {
    background: #3498db;
    color: white;
}

.boton-volver:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

/* ============================================
   MENSAJES DE ALERTA
   ============================================ */
.mensaje {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
    display: none;
}

.mensaje.activo {
    display: block;
}

.mensaje-exito {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.mensaje-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.mensaje-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ============================================
   LOADER / CARGANDO
   ============================================ */
.cargando {
    display: none;
    text-align: center;
    padding: 20px;
}

.cargando.activo {
    display: block;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: girar 1s linear infinite;
    margin: 0 auto 15px;
}

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

/* ============================================
   RESPONSIVE - TABLETS
   ============================================ */
@media (max-width: 768px) {
    .encabezado h1 {
        font-size: 2em;
    }
    
    .grid-formularios {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
    }
    
    .tarjeta-formulario {
        padding: 20px;
    }
    
    .icono-formulario {
        font-size: 2.5em;
    }
    
    .contenedor-formulario {
        padding: 20px 15px;
    }
    
    .fila-campos {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   RESPONSIVE - MÓVILES
   ============================================ */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .encabezado {
        padding: 20px 15px;
    }
    
    .encabezado h1 {
        font-size: 1.5em;
    }
    
    .encabezado p {
        font-size: 0.95em;
    }
    
    .contenedor-dashboard {
        padding: 20px 15px;
    }
    
    .titulo-seccion {
        font-size: 1.4em;
    }
    
    .grid-formularios {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .contenedor-botones {
        flex-direction: column;
    }
    
    .boton {
        width: 100%;
    }
}

/* ============================================
   UTILIDADES
   ============================================ */
.oculto {
    display: none !important;
}

.campo-deshabilitado {
    background-color: #f5f5f5 !important;
    cursor: not-allowed !important;
}

.texto-centrado {
    text-align: center;
}

.margen-superior {
    margin-top: 20px;
}

/* ============================================
   MENÚ DE USUARIO
   ============================================ */
.menu-usuario {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.2);
    flex-wrap: wrap;
    gap: 15px;
}

.info-usuario {
    display: flex;
    align-items: center;
    gap: 15px;
}

.foto-usuario {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.foto-usuario-placeholder {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8em;
    border: 3px solid white;
}

.datos-usuario {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.datos-usuario strong {
    font-size: 1.1em;
    color: white;
}

.perfil-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
}

.perfil-administrador {
    background: #e74c3c;
    color: white;
}

.perfil-supervisor {
    background: #f39c12;
    color: white;
}

.perfil-operador {
    background: #3498db;
    color: white;
}

.acciones-usuario {
    display: flex;
    gap: 10px;
}

.btn-menu {
    padding: 8px 16px;
    border: 2px solid white;
    background: rgba(255,255,255,0.1);
    color: white;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-menu:hover {
    background: white;
    color: #2a5298;
    transform: translateY(-2px);
}

.btn-logout {
    background: rgba(231, 76, 60, 0.2);
    border-color: #e74c3c;
}

.btn-logout:hover {
    background: #e74c3c;
    color: white;
    border-color: #e74c3c;
}

/* ============================================
   TABLA DE PERMISOS
   ============================================ */
.tabla-permisos {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.tabla-permisos thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.tabla-permisos th,
.tabla-permisos td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.tabla-permisos th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.9em;
    letter-spacing: 0.5px;
}

.tabla-permisos tbody tr:hover {
    background: #f8f9ff;
}

.tabla-permisos tbody tr:last-child td {
    border-bottom: none;
}

.checkbox-permiso {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.pantalla-nombre {
    font-weight: 600;
    color: #2a5298;
}

.pantalla-icono {
    font-size: 1.5em;
    margin-right: 8px;
}

/* ============================================
   SELECTOR DE USUARIO EN PERMISOS
   ============================================ */
.selector-usuario {
    background: #f8f9ff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    border: 2px solid #e0e0e0;
}

.selector-usuario label {
    display: block;
    margin-bottom: 10px;
    color: #2a5298;
    font-weight: 600;
    font-size: 1.1em;
}

.selector-usuario select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    background: white;
    cursor: pointer;
}

/* ============================================
   RESPONSIVE MENÚ USUARIO
   ============================================ */
@media (max-width: 768px) {
    .menu-usuario {
        flex-direction: column;
        text-align: center;
    }
    
    .info-usuario {
        flex-direction: column;
    }
    
    .acciones-usuario {
        width: 100%;
        flex-direction: column;
    }
    
    .btn-menu {
        width: 100%;
    }
    
    .tabla-permisos {
        font-size: 0.9em;
    }
    
    .tabla-permisos th,
    .tabla-permisos td {
        padding: 8px 10px;
    }
}

/* ============================================
   AUDITORÍA
   ============================================ */
.filtros-auditoria {
    background: #f8f9ff;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 25px;
    border: 2px solid #e0e0e0;
}

.paginacion {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Tabla de logs responsive */
@media (max-width: 768px) {
    .tabla-permisos {
        font-size: 0.85em;
    }
    
    .tabla-permisos th,
    .tabla-permisos td {
        padding: 8px 6px;
    }
    
    .filtros-auditoria {
        padding: 15px;
    }
}

/* ============================================
   REPORTES
   ============================================ */
.filtros-reporte {
    background: #f8f9ff;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    border: 2px solid #e0e0e0;
}

.estadisticas-reporte {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
    border-left: 4px solid #2a5298;
}

.stat-numero {
    font-size: 2.5em;
    font-weight: 700;
    color: #2a5298;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   NOTIFICACIONES Y BADGES
   ============================================ */
@keyframes badge-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(231, 76, 60, 0.4);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 4px 16px rgba(231, 76, 60, 0.6);
    }
}

.badge-pulse {
    animation: badge-pulse 1s ease-in-out;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .estadisticas-reporte {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-numero {
        font-size: 2em;
    }
    
    #modal-editar-supervisor > div {
        width: 95% !important;
        margin: 5% auto !important;
    }
}

/* ============================================
   SELECT CON BÚSQUEDA FILTRABLE
   ============================================ */
.select-searchable {
    position: relative;
    width: 100%;
}

.select-searchable input {
    width: 100%;
    padding: 12px 35px 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    transition: all 0.3s ease;
    background: white url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23666" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>') no-repeat right 10px center;
    cursor: pointer;
}

.select-searchable input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    cursor: text;
}

.dropdown-opciones {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #667eea;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-top: -2px;
}

.dropdown-opciones::-webkit-scrollbar {
    width: 8px;
}

.dropdown-opciones::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 0 8px 0;
}

.dropdown-opciones::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.dropdown-opciones::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

.opcion-item {
    padding: 12px 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
    font-size: 0.95em;
}

.opcion-item:last-child {
    border-bottom: none;
}

.opcion-item:hover {
    background: #f8f9ff;
    color: #667eea;
    font-weight: 500;
}

.opcion-item.seleccionado {
    background: #667eea;
    color: white;
    font-weight: 600;
}

.opcion-no-encontrada {
    padding: 20px 15px;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* Animación de aparición */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-opciones {
    animation: slideDown 0.2s ease;
}

/* ============================================
   ESTILOS DE CONTROL DE PERMISOS
   ============================================ */

/* Campos bloqueados por permisos */
input[data-permiso-bloqueado="true"],
select[data-permiso-bloqueado="true"],
textarea[data-permiso-bloqueado="true"] {
    background-color: #f5f5f5 !important;
    cursor: not-allowed !important;
    opacity: 0.7;
    border-color: #ddd !important;
    color: #666 !important;
}

input[data-permiso-bloqueado="true"]::placeholder,
textarea[data-permiso-bloqueado="true"]::placeholder {
    color: #999 !important;
    opacity: 0.6;
}

/* Botones bloqueados por permisos */
button[data-permiso-bloqueado="true"] {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    filter: grayscale(0.5);
    pointer-events: none;
}

button[data-permiso-bloqueado="true"]:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Mensaje de permisos restricción */
.mensaje-permisos-restriccion {
    animation: slideDown 0.4s ease-out;
}

/* Indicador visual de solo lectura en formularios */
.formulario.solo-lectura::before {
    content: '🔒 MODO SOLO LECTURA';
    display: block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    text-align: center;
    font-weight: bold;
    margin-bottom: 20px;
    font-size: 0.9em;
    letter-spacing: 0.5px;
}
