/* admin-panel-enhanced.css - Estilos para el panel administrativo mejorado */

.admin-panel-enhanced {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.panel-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.panel-header h2 {
    margin: 0 0 10px 0;
    font-size: 2em;
}

.panel-header p {
    margin: 0;
    opacity: 0.9;
}

.panel-content {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
    min-height: 600px;
}

/* Sección de usuarios mejorada */
.users-section {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    height: fit-content;
    min-height: 600px;
}

.users-section h3 {
    margin: 0 0 20px 0;
    color: #333;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.users-count {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 500;
}

/* Barra de búsqueda y filtros */
.users-controls {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.search-bar {
    position: relative;
    display: flex;
    gap: 10px;
}

.search-input {
    flex: 1;
    padding: 12px 16px 12px 40px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 16px;
}

.filter-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    min-width: 120px;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.sort-label {
    font-size: 14px;
    color: #666;
    white-space: nowrap;
}

/* Vista de tabla para usuarios */
.users-table-container {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    max-height: 500px;
    overflow-y: auto;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.users-table th {
    background: #f8f9fa;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #e0e0e0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.users-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
}

.users-table th.sortable:hover {
    background: #e9ecef;
}

.users-table th.sortable::after {
    content: ' ↕️';
    opacity: 0.5;
    font-size: 12px;
}

.users-table th.sort-asc::after {
    content: ' ↑';
    opacity: 1;
    color: #667eea;
}

.users-table th.sort-desc::after {
    content: ' ↓';
    opacity: 1;
    color: #667eea;
}

.users-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.users-table tr:hover {
    background: #f8f9ff;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.user-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.user-email {
    color: #666;
    font-size: 12px;
}

.user-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.user-status.active {
    background: #d4edda;
    color: #155724;
}

.user-status.inactive {
    background: #f8d7da;
    color: #721c24;
}

.user-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.action-btn.edit {
    background: #667eea;
    color: white;
}

.action-btn.edit:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

.action-btn.delete {
    background: #dc3545;
    color: white;
}

.action-btn.delete:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.action-btn.view {
    background: #28a745;
    color: white;
}

.action-btn.view:hover {
    background: #218838;
    transform: translateY(-1px);
}

/* Paginación */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 15px 0;
    border-top: 1px solid #e0e0e0;
}

.pagination-info {
    color: #666;
    font-size: 14px;
}

.pagination {
    display: flex;
    gap: 5px;
    align-items: center;
}

.pagination-btn {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: white;
    color: #333;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: #f8f9fa;
    border-color: #667eea;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.pagination-ellipsis {
    padding: 8px 4px;
    color: #999;
}

/* Estados de carga y vacío */
.users-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.users-empty {
    text-align: center;
    padding: 40px;
    color: #999;
}

.users-empty i {
    font-size: 48px;
    color: #ddd;
    margin-bottom: 16px;
    display: block;
}

/* Responsive para tabla */
@media (max-width: 768px) {
    .users-table-container {
        overflow-x: auto;
    }
    
    .users-table {
        min-width: 600px;
    }
    
    .filter-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .sort-controls {
        margin-left: 0;
        justify-content: center;
    }
    
    .pagination-container {
        flex-direction: column;
        gap: 15px;
    }
}

/* Sección de permisos */
.permissions-section {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.permissions-section h3 {
    margin: 0 0 20px 0;
    color: #333;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.permissions-container {
    max-height: 600px;
    overflow-y: auto;
    padding-right: 10px;
}

.permissions-container::-webkit-scrollbar {
    width: 6px;
}

.permissions-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.permissions-container::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 3px;
}

.permissions-section h4 {
    margin: 20px 0 15px 0;
    color: #555;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.permissions-section h4:first-child {
    margin-top: 0;
}

/* Items de permisos */
.permission-item {
    margin: 8px 0;
    padding: 5px 0;
}

.permission-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    user-select: none;
}

.permission-label:hover {
    background-color: #f8f9ff;
}

.permission-checkbox {
    width: 18px;
    height: 18px;
    accent-color: #667eea;
    cursor: pointer;
}

.permission-label i {
    color: #667eea;
    width: 20px;
    text-align: center;
}

.permission-label span {
    color: #333;
    font-weight: 500;
}

.required {
    color: #e74c3c;
    font-weight: bold;
    margin-left: 5px;
}

/* Niveles de indentación */
.level-0 {
    margin-left: 0;
}

.level-1 {
    margin-left: 20px;
    border-left: 2px solid #e0e0e0;
    padding-left: 15px;
}

.level-2 {
    margin-left: 40px;
    border-left: 2px solid #e0e0e0;
    padding-left: 15px;
}

.level-3 {
    margin-left: 60px;
    border-left: 2px solid #e0e0e0;
    padding-left: 15px;
}

/* Botones de acción */
.permissions-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9em;
}

/* Responsive */
@media (max-width: 768px) {
    .panel-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .permissions-actions {
        flex-direction: column;
    }
    
    .btn {
        justify-content: center;
    }
}

/* Estados especiales */
.permission-item.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.permission-item.required {
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.permissions-section {
    animation: fadeIn 0.3s ease;
}

/* Estructura compacta del Compendio */
.compendio-permissions {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.testament-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    border: 1px solid #e9ecef;
}

.books-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 10px;
}

.section-group {
    background: white;
    border-radius: 6px;
    padding: 12px;
    border: 1px solid #dee2e6;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-weight: 600;
    color: #495057;
}

.section-header input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #667eea;
}

.section-header i {
    color: #667eea;
    width: 18px;
}

.books-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
}

.book-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.book-item:hover {
    background: #e9ecef;
    border-color: #667eea;
}

.book-item input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #667eea;
}

.book-item i {
    color: #667eea;
    font-size: 0.9em;
    width: 16px;
}

.book-item span {
    font-size: 0.85em;
    color: #495057;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.other-content {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    border: 1px solid #e9ecef;
}

.other-content h5 {
    margin: 0 0 15px 0;
    color: #495057;
    font-size: 1em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.other-content .books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}

/* Responsive mejorado */
@media (max-width: 1200px) {
    .books-row {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
    
    .other-content .books-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
}

@media (max-width: 768px) {
    .panel-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .books-row {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }
    
    .other-content .books-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
    
    .book-item span {
        font-size: 0.8em;
    }
}

/* Indicadores visuales */
.permission-item[data-permission="acceso_compendio"] {
    background: linear-gradient(90deg, #e8f5e8 0%, transparent 100%);
    border-left: 4px solid #28a745;
}

.permission-item[data-permission="panel_admin"] {
    background: linear-gradient(90deg, #fff3cd 0%, transparent 100%);
    border-left: 4px solid #ffc107;
}

/* Estilos para checkboxes con estado indeterminado */
.permission-checkbox:indeterminate {
    background-color: #667eea;
    border-color: #667eea;
    position: relative;
}

.permission-checkbox:indeterminate::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 2px;
    background-color: white;
    border-radius: 1px;
}

/* Estilos mejorados para checkboxes padre */
.permission-item.level-0 .permission-checkbox {
    transform: scale(1.2);
    margin-right: 8px;
}

.permission-item.level-0 .permission-checkbox:indeterminate {
    background-color: #ffc107;
    border-color: #ffc107;
}

/* Estilos para secciones colapsables */
.section-header {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease;
}

.section-header:hover {
    background-color: #f8f9fa;
}

.section-header .permission-checkbox {
    margin-right: 8px;
}

/* Indicador visual para secciones con hijos */
.section-header::after {
    content: '▼';
    float: right;
    transition: transform 0.2s ease;
    color: #667eea;
}

.section-header.collapsed::after {
    transform: rotate(-90deg);
}

/* Animación suave para mostrar/ocultar contenido */
.section-content {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.section-content.collapsed {
    max-height: 0;
}