/* css/dashboardstyle.css - VERSIÓN LIMPIA Y CORREGIDA */
/* Este archivo SOLO contiene estilos para el Usuario, Dropdown, Tablas y Modales */
/* No toca la navegación ni el layout principal */

/* --- 1. CORRECCIÓN DEL CONTENEDOR DE USUARIO --- */
/* Sobrescribimos la regla de style.css que tenía overflow:hidden */
.user {
    position: relative !important;
    overflow: visible !important; /* VITAL: Permite que el menú salga del círculo */
    width: 40px;
    height: 40px;
    cursor: pointer;
    z-index: 1001;
    background: transparent !important; /* Quitamos el fondo azul del contenedor padre */
}

/* --- 2. EL AVATAR (EL CÍRCULO VISIBLE) --- */
.user-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background-color: var(--white);
    color: var(--blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 2px solid var(--blue); /* Borde para que destaque */
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.user-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(28, 98, 185, 0.2);
}

/* --- 3. EL MENÚ DESPLEGABLE (DROPDOWN) --- */
.user-dropdown {
    display: none; /* Oculto por defecto */
    position: absolute;
    top: 54px; /* Debajo del usuario */
    right: 0;
    background-color: #fff; /* Usamos hex directo por seguridad */
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border-radius: 12px;
    overflow: hidden;
    z-index: 9999;
    min-width: 180px;
    border: 1px solid #e2e8f0;
}

/* Esta clase la agrega JS */
.user-dropdown.show {
    display: block !important;
    animation: fadeIn 0.2s ease;
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: #475569;
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-weight: 500;
}

.user-dropdown a:hover {
    background-color: #f8fafc;
    color: #1c62b9;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- 4. ESTILOS DE LA TABLA DE ADMINISTRACIÓN --- */
.admin-container {
    padding: 24px;
    margin-top: 20px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 24px;
}

/* Botones */
.btn-primary {
    background: linear-gradient(135deg, #1c62b9 0%, #062f76 100%);
    color: #fff;
    padding: 12px 24px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(28, 98, 185, 0.2);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(28, 98, 185, 0.3); filter: brightness(1.1); }
.btn-primary:active { transform: translateY(0); }

/* Tabla */
.user-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    border: 1px solid #e2e8f0;
}

.user-table th {
    background: #f1f5f9;
    color: #475569;
    padding: 16px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e2e8f0;
}

.user-table td {
    padding: 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    font-size: 0.95rem;
}

.user-table tr {
    transition: background 0.2s ease;
}

.user-table tr:hover {
    background: #f8fafc;
}

/* Badges y Acciones */
.badge { padding: 6px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 700; }
.badge-active { background: #d1fae5; color: #059669; }
.badge-inactive { background: #fee2e2; color: #dc2626; }

.btn-action { border: none; background: none; font-size: 1.3rem; cursor: pointer; margin: 0 6px; transition: transform 0.2s; }
.btn-edit { color: #f59e0b; }
.btn-delete { color: #ef4444; }
.btn-action:hover { transform: scale(1.1); }

/* --- 5. MODAL Y FORMULARIOS (Reemplaza esta sección al final de dashboardstyle.css) --- */
.modal {
    display: none;
    position: fixed;
    z-index: 20000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.6);
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px); /* Efecto borroso en el fondo */
}

.modal.active { display: flex !important; }

.modal-content {
    background-color: #fff;
    padding: 40px 40px; /* Más espacio interno */
    border-radius: 16px;
    width: 550px;
    max-width: 95%;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-content h3 {
    color: #0f172a; /* var(--blue) */
    margin-bottom: 30px;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #94a3b8;
    transition: 0.2s;
    background: #f1f5f9;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.close-modal:hover { color: white; background: #ef4444; transform: rotate(90deg); }

/* --- ESTILOS DE LOS INPUTS (CORREGIDO) --- */
.inputBox { 
    position: relative; 
    margin-bottom: 28px; 
    width: 100%;
}

.inputBox input {
    width: 100%; 
    padding: 14px 16px; /* Más espacio para escribir */
    border: 1px solid #e2e8f0;
    border-radius: 10px; 
    outline: none;
    font-size: 1rem;
    color: #1e293b;
    transition: all 0.3s ease;
    background: transparent;
    font-weight: 500;
}

/* Efecto al hacer clic en el input */
.inputBox input:focus {
    border-color: #1c62b9; /* Borde azul al escribir */
    box-shadow: 0 0 0 4px rgba(28, 98, 185, 0.1);
}

/* La etiqueta flotante (Nombre, Usuario, etc.) */
.inputBox span {
    position: absolute; 
    left: 14px; 
    top: 0;
    transform: translateY(-50%); /* Centra la etiqueta en la línea superior */
    background: #fff; /* Tapa la línea de atrás */
    padding: 0 6px;
    font-size: 0.85rem;
    color: #1c62b9; 
    font-weight: 700;
    pointer-events: none; /* Permite hacer clic a través del texto */
    letter-spacing: 0.5px;
}

/* Nota pequeña (Dejar en blanco...) */
small {
    display: block;
    margin-top: -15px;
    margin-bottom: 20px;
    color: #64748b;
    font-size: 0.85rem;
    font-style: italic;
}

/* --- CHECKBOXES MEJORADOS --- */
.permisos-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 24px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.permiso-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    color: #475569;
    font-weight: 500;
}

.permiso-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #1c62b9;
    cursor: pointer;
}

/* Footer del modal (Botones) */
.modal-footer {
    margin-top: 32px;
    display: flex;
    justify-content: flex-end;
    gap: 16px;
}

.btn-cancelar {
    background: transparent;
    border: 1px solid #e2e8f0;
    color: #475569;
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.3s;
    font-size: 0.95rem;
}
.btn-cancelar:hover { background: #f8fafc; border-color: #cbd5e1; color: #1e293b; }

.btn-guardar {
    background: linear-gradient(135deg, #1c62b9 0%, #062f76 100%);
    border: none;
    color: #fff;
    padding: 12px 32px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(28, 98, 185, 0.2);
}
.btn-guardar:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(28, 98, 185, 0.3); filter: brightness(1.1); }

.user-cell {
    display: flex;
    flex-direction: column; /* Alinea uno arriba del otro */
    line-height: 1.4;       /* Da espacio entre líneas */
}

.user-main-name {
    font-weight: 700;
    color: #1c62b9;         /* Un color azul para resaltar el nombre */
    font-size: 1rem;
}

.user-sub-id {
    font-size: 0.8rem;
    color: #64748b;            /* Gris para que el ID sea secundario */
    margin-top: 2px;       /* Ajuste fino de posición */
}

/* Mejora general para que la tabla no se vea apretada */
.log-table td {
    vertical-align: middle; /* Centra el contenido verticalmente */
    padding: 14px 12px;     /* Más espacio en las celdas */
}

/* --- 7. NUEVOS ESTILOS PARA MODAL DE PERMISOS (AÑADIDO) --- */

.permiso-group {
    margin-top: 25px;
    border-top: 1px solid #e2e8f0;
    padding-top: 24px;
}

.permiso-group h5 {
    font-size: 0.9rem;
    color: #1c62b9;
    text-transform: uppercase;
    margin-bottom: 16px;
    letter-spacing: 0.5px;
    font-weight: 700;
}

.permiso-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #f1f5f9;
}
.permiso-row:last-child {
    border-bottom: none;
}

.permiso-info {
    display: flex;
    flex-direction: column;
}

.permiso-info label {
    font-weight: 600;
    color: #1e293b;
    font-size: 1rem;
}

.permiso-descripcion {
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 4px;
    font-style: italic;
}

/* Estilos para etiquetas con importancia */
.label-importante { color: #ef4444 !important; font-weight: 700 !important; }
.label-destacado-1 { color: #10b981 !important; font-weight: 600 !important; }
.label-destacado-2 { color: #1c62b9 !important; font-weight: 600 !important; }

/* Estilos para Selects en el nuevo layout */
.select-label {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 10px;
    display: block;
}
.inputBox select {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background-color: #f8fafc;
    font-size: 0.95rem;
    color: #1e293b;
    transition: all 0.3s ease;
}
.inputBox select:focus {
    border-color: #1c62b9;
    box-shadow: 0 0 0 4px rgba(28, 98, 185, 0.1);
    outline: none;
}
.select-descripcion {
    margin-top: 8px !important;
    padding-bottom: 12px;
}

/* --- ESTILOS PARA EL INTERRUPTOR (TOGGLE SWITCH) --- */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    flex-shrink: 0; /* Evita que se encoja */
    margin-left: 15px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #10b981; /* Color verde primario */
}

input:focus + .slider {
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

@media (max-width: 768px) {
    /* Ajustamos el contenedor principal y la barra de herramientas */
    .admin-container {
        padding: 16px;
    }

    .toolbar {
        flex-direction: column;
        gap: 12px;
        align-items: stretch; /* Los botones ocuparán todo el ancho */
    }

    .btn-primary {
        width: 100%;
        justify-content: center; /* Centramos el texto del botón */
    }

    /* Ajustes para el modal */
    .modal-content {
        width: 95%;
        padding: 32px 20px;
    }

    .modal-content h3 {
        font-size: 1.4rem;
    }

    .permisos-grid {
        grid-template-columns: 1fr; /* Una sola columna para los permisos */
    }

    .modal-footer {
        flex-direction: column;
        gap: 12px;
    }

    .btn-cancelar, .btn-guardar {
        width: 100%;
        justify-content: center;
    }
}