/* ==========================================================================
   PERFIL DE USUARIO - Avatar y Menú Desplegable
   Derbis HN - Inspirado en diseño moderno
   ========================================================================== */

/* Contenedor del avatar en el header */
.user-profile-container {
    position: relative;
    margin-left: auto;
    z-index: 1000;
}

/* Avatar circular */
.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 3px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.user-avatar:hover {
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* Letra inicial dentro del avatar */
.user-avatar-letter {
    font-size: 20px;
    font-weight: bold;
    color: white;
    text-transform: uppercase;
    user-select: none;
}

/* Imagen de perfil dentro del avatar */
.user-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Indicador online */
.user-avatar::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #00ff88;
    border: 2px solid var(--color-fondo);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.6);
}

/* ==========================================================================
   MENÚ DESPLEGABLE
   ========================================================================== */

.user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 280px;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Flecha del dropdown */
.user-dropdown::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 15px;
    width: 16px;
    height: 16px;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
    transform: rotate(45deg);
}

/* Header del dropdown con info de usuario */
.dropdown-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
}

.dropdown-header-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    font-size: 24px;
    font-weight: bold;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.dropdown-username {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 5px;
}

.dropdown-email {
    font-size: 13px;
    opacity: 0.9;
}

.dropdown-role {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Stats en el header */
.dropdown-stats {
    display: flex;
    justify-content: space-around;
    padding: 15px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 18px;
    font-weight: bold;
    color: var(--color-texto);
}

.stat-label {
    display: block;
    font-size: 11px;
    color: var(--color-muted);
    text-transform: uppercase;
    margin-top: 2px;
}

/* Items del menú */
.dropdown-menu {
    padding: 8px 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--color-texto);
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.dropdown-item:hover {
    background: rgba(102, 126, 234, 0.1);
    border-left-color: #667eea;
    padding-left: 25px;
}

.dropdown-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--color-muted);
    transition: all 0.2s ease;
}

.dropdown-item:hover .dropdown-item-icon {
    color: #667eea;
    transform: scale(1.1);
}

.dropdown-item-text {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.dropdown-item-badge {
    background: #667eea;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

/* Separador */
.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}

/* Item de cerrar sesión (especial) */
.dropdown-item.logout {
    color: #dc3545;
    margin-top: 5px;
}

.dropdown-item.logout:hover {
    background: rgba(220, 53, 69, 0.1);
    border-left-color: #dc3545;
}

.dropdown-item.logout .dropdown-item-icon {
    color: #dc3545;
}

/* ==========================================================================
   MODAL DE GESTIÓN DE USUARIOS
   ========================================================================== */

.modal-gestion-usuarios {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.modal-gestion-usuarios.show {
    display: flex;
}

.modal-gestion-content {
    background: var(--bg-card);
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: slideInUp 0.4s ease-out;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-gestion-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-gestion-header h2 {
    margin: 0;
    font-size: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-gestion-body {
    padding: 30px;
    overflow-y: auto;
    max-height: calc(85vh - 100px);
}

/* Filtros */
.usuarios-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.filter-input {
    flex: 1;
    min-width: 200px;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-card);
    color: var(--text-color);
}

.filter-input:focus {
    outline: none;
    border-color: #667eea;
}

.filter-select {
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-card);
    color: var(--text-color);
    cursor: pointer;
}

/* Tabla de usuarios */
.usuarios-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
}

.usuarios-table thead {
    background: rgba(102, 126, 234, 0.1);
}

.usuarios-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--color-texto);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.usuarios-table td {
    padding: 15px;
    border-top: 1px solid var(--border-color);
    color: var(--color-texto);
}

.usuario-avatar-small {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    margin-right: 10px;
}

.usuario-info {
    display: flex;
    align-items: center;
}

.usuario-nombre {
    font-weight: 600;
    display: block;
}

.usuario-email {
    font-size: 12px;
    color: var(--color-muted);
    display: block;
}

.rol-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.rol-badge.user {
    background: rgba(108, 117, 125, 0.2);
    color: #6c757d;
}

.rol-badge.mod {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
}

.rol-badge.dev {
    background: rgba(220, 53, 69, 0.2);
    color: #dc3545;
}

.rol-badge.premium {
    background: rgba(102, 126, 234, 0.2);
    color: #667eea;
}

.btn-change-rol {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-change-rol:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-muted);
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.3;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-gestion-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .usuarios-table {
        font-size: 13px;
    }
    
    .usuarios-table th,
    .usuarios-table td {
        padding: 10px;
    }
    
    .usuario-avatar-small {
        width: 32px;
        height: 32px;
    }
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .user-dropdown {
        width: 260px;
        right: -10px;
    }
    
    .user-avatar {
        width: 40px;
        height: 40px;
    }
    
    .user-avatar-letter {
        font-size: 18px;
    }
}

/* ==========================================================================
   MODO OSCURO
   ========================================================================== */

[data-theme="dark"] .user-dropdown {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .dropdown-item:hover {
    background: rgba(102, 126, 234, 0.15);
}

/* Animación de aparición */
@keyframes dropdownSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-dropdown.show {
    animation: dropdownSlide 0.3s ease-out;
}